1931. Painting a Grid With Three Different Colors
Last updated
Last updated
https://leetcode.com/problems/painting-a-grid-with-three-different-colors
You are given two integers m
and n
. Consider an m x n
grid where each cell is initially white. You can paint each cell red, green, or blue. All cells must be painted.
Return the number of ways to color the grid with no two adjacent cells having the same color. Since the answer can be very large, return it modulo 109 + 7
.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= m <= 5
1 <= n <= 1000