java.lang.Object
g2501_2600.s2579_count_total_number_of_colored_cells.Solution

public class Solution extends Object
2579 - Count Total Number of Colored Cells.<p>Medium</p> <p>There exists an infinitely large two-dimensional grid of uncolored unit cells. You are given a positive integer <code>n</code>, indicating that you must do the following routine for <code>n</code> minutes:</p> <ul> <li>At the first minute, color <strong>any</strong> arbitrary unit cell blue.</li> <li>Every minute thereafter, color blue <strong>every</strong> uncolored cell that touches a blue cell.</li> </ul> <p>Below is a pictorial representation of the state of the grid after minutes 1, 2, and 3.</p> <p><img src="https://assets.leetcode.com/uploads/2023/01/10/example-copy-2.png" alt="" /></p> <p>Return <em>the number of <strong>colored cells</strong> at the end of</em> <code>n</code> <em>minutes</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = 1</p> <p><strong>Output:</strong> 1</p> <p><strong>Explanation:</strong> After 1 minute, there is only 1 blue cell, so we return 1.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 2</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong> After 2 minutes, there are 4 colored cells on the boundary and 1 in the center, so we return 5.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n <= 10<sup>5</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • coloredCells

      public long coloredCells(int n)