Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Paint N × 3 Grid

med
30 min
Try to solve the Number of Ways to Paint N × 3 Grid problem.

Statement

You are given an integer n representing the number of rows in a grid of size n $ imes$ 33. You want to paint each cell of the grid using one of 33 colors: Red, Yellow, or Green, such that no two adjacent cells share the same color. Two cells are considered adjacent if they share a common edge.

Return the total number of ways to paint the grid. Since the result can be very large, return it modulo 109+710^9 + 7.

Constraints:

  • n == grid.length

  • 1≤1 \leq n ≤5000\leq 5000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Paint N × 3 Grid

med
30 min
Try to solve the Number of Ways to Paint N × 3 Grid problem.

Statement

You are given an integer n representing the number of rows in a grid of size n $ imes$ 33. You want to paint each cell of the grid using one of 33 colors: Red, Yellow, or Green, such that no two adjacent cells share the same color. Two cells are considered adjacent if they share a common edge.

Return the total number of ways to paint the grid. Since the result can be very large, return it modulo 109+710^9 + 7.

Constraints:

  • n == grid.length

  • 1≤1 \leq n ≤5000\leq 5000