diff --git a/javascript/2579-count-total-number-of-colored-cells.js b/javascript/2579-count-total-number-of-colored-cells.js new file mode 100644 index 000000000..2cd412826 --- /dev/null +++ b/javascript/2579-count-total-number-of-colored-cells.js @@ -0,0 +1,17 @@ +/** + * Brute Force | Math + * Time O(n) | Space O(1) + * https://leetcode.com/problems/count-total-number-of-colored-cells + * @param {number} n + * @return {number} + */ +var coloredCells = function(n) { + + let total = 1; + n--; + while (n) { + total += 4*n; + n--; + } + return total; +};