1411. Number of Ways to Paint N × 3 Grid Hard
1/**
2 * [1411] Number of Ways to Paint N × 3 Grid
3 *
4 * You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cells that share vertical or horizontal sides have the same color).
5 * Given n the number of rows of the grid, return the number of ways you can paint this grid. As the answer may grow large, the answer must be computed modulo 10^9 + 7.
6 *
7 * Example 1:
8 * <img alt="" src="https://assets.leetcode.com/uploads/2020/03/26/e1.png" style="width: 400px; height: 257px;" />
9 * Input: n = 1
10 * Output: 12
11 * Explanation: There are 12 possible way to paint the grid as shown.
12 *
13 * Example 2:
14 *
15 * Input: n = 5000
16 * Output: 30228214
17 *
18 *
19 * Constraints:
20 *
21 * n == grid.length
22 * 1 <= n <= 5000
23 *
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid/
28// discuss: https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33 pub fn num_of_ways(n: i32) -> i32 {
34 0
35 }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn test_1411() {
46 }
47}
48
Back
© 2025 bowen.ge All Rights Reserved.