Skip to content

Commit 511a590

Browse files
authored
Create 2579-count-total-number-of-colored-cells.js
Solved count-total-number-of-colored-cells
1 parent 3a66f08 commit 511a590

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Brute Force | Math
3+
* Time O(n) | Space O(1)
4+
* https://leetcode.com/problems/count-total-number-of-colored-cells
5+
* @param {number} n
6+
* @return {number}
7+
*/
8+
var coloredCells = function(n) {
9+
10+
let total = 1;
11+
n--;
12+
while (n) {
13+
total += 4*n;
14+
n--;
15+
}
16+
return total;
17+
};

0 commit comments

Comments
 (0)