Skip to content

Practice Count Total Number of Colored Cells

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2579
LeetCode Problem

Count Total Number of Colored Cells

Problem Statement

On an infinite grid, color one cell in minute 1. Each later minute, simultaneously color every uncolored cell sharing an edge with an already colored cell. Return the total colored cells after n minutes.

Source: Count Total Number of Colored Cells on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 1
Output
1

# Example 2

Input
n = 2
Output
5

Constraints

1 <= n <= 10^5

Related LeetCode Problems

Practice more problems similar to Count Total Number of Colored Cells.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.