Available question text
Count the number of ways to color an m×n grid with 3 colors so that no two adjacent cells (horizontally or vertically) share a color; with m ≤ 5 and n ≤ 1000, the typical approach is to enumerate valid column colorings (state compression), build transitions between compatible columns, and perform DP or matrix exponentiation across n columns modulo 1e9+7.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1931. Painting a Grid With Three Different Colors
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source