Advertisement
2579. Count Total Number of Colored Cells
MediumView on LeetCode
Time: O(1)
Space: O(1)
Approach
After n minutes the colored diamond has n² + (n-1)² cells.
2579.cs
C#
// Approach: After n minutes the colored diamond has n² + (n-1)² cells.
// Time: O(1) Space: O(1)
public class Solution
{
public long ColoredCells(int n)
{
return 1L * n * n + 1L * (n - 1) * (n - 1);
}
}Advertisement
Was this solution helpful?