Practice Painting a Grid With Three Different Colors
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
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 10^9 + 7.
Source: Painting a Grid With Three Different Colors on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
m = 1, n = 1
3
# Example 2
m = 1, n = 2
6
# Example 3
m = 5, n = 5
580986
Constraints
Related LeetCode Problems
Practice more problems similar to Painting a Grid With Three Different Colors.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.