Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Paint N × 3 Grid

Number of Ways to Paint N × 3 Grid asks you to count ways to color an n-row, three-column grid with three colors, ensuring edge-sharing cells differ, and return the total modulo a large prime.

Statement

You are given an integer n representing the number of rows in a grid of size n ×\times 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

Number of Ways to Paint N × 3 Grid asks you to count ways to color an n-row, three-column grid with three colors, ensuring edge-sharing cells differ, and return the total modulo a large prime.

Statement

You are given an integer n representing the number of rows in a grid of size n ×\times 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