HTMLify
LeetCode - Count Total Number of Colored Cells - Go
Views: 283 | Author: abh
1 2 3 4 5 6 7 8 9 10 11 | func coloredCells(n int) int64 { var ans int for i:=1; i<=n; i++ { if i == 1 { ans += 1 } else { ans += 4*(i)-4 } } return int64(ans) } |