DUNZO DIGITAL Off-Campus OA (2023) | Count Total Number of Colored Cells

Question · Posted Jun 2026

Problem Statement There is an infinite grid. At minute 1, exactly one cell is colored. Every minute afterward, all uncolored neighboring cells of currently colored cells become colored. Return the total number of colored cells after n minutes. Example Input n = 1 Output 1 Constraints 1 <= n <= 100000 Observation The pattern of colored cells becomes: Minute 1 → 1 Minute 2 → 5 Minute 3 → 13 Minute 4 → 25 Minute 5 → 41 Differences: +4, ...

The full answer & interview discussion are available to premium members.

Log in Create a free account