Back to problems

Three-Column Grid Coloring Count

Algorithm · Intuit · Medium

Examples Example 1 Example 2 Requirements For an n x 3 board with three possible colors, determine how many legal color assignments exist. Constraints and conditions: n is at most 20000. Report the answer modulo 1_000_000_007. Two horizontally neighboring cells within a row must receive different colors. Two vertically neighboring cells within a column must also receive different colors. Notes A row-by-row dynamic-programming approach is the straightforward method. Because…

Checking your access…