Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 1931. Painting a Grid With Three Different Colors
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.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.