HTMLify
LeetCode - Count Total Number of Colored Cells - Go
Views: 134 | Author: abh
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)
}