Skip to content

Commit b59cd8a

Browse files
committed
Add solution #2579
1 parent a2b0455 commit b59cd8a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@
711711
2535|[Difference Between Element Sum and Digit Sum of an Array](./2535-difference-between-element-sum-and-digit-sum-of-an-array.js)|Easy|
712712
2542|[Maximum Subsequence Score](./2542-maximum-subsequence-score.js)|Medium|
713713
2570|[Merge Two 2D Arrays by Summing Values](./2570-merge-two-2d-arrays-by-summing-values.js)|Easy|
714+
2579|[Count Total Number of Colored Cells](./2579-count-total-number-of-colored-cells.js)|Medium|
714715
2618|[Check if Object Instance of Class](./2618-check-if-object-instance-of-class.js)|Medium|
715716
2619|[Array Prototype Last](./2619-array-prototype-last.js)|Easy|
716717
2620|[Counter](./2620-counter.js)|Easy|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* 2579. Count Total Number of Colored Cells
3+
* https://leetcode.com/problems/count-total-number-of-colored-cells/
4+
* Difficulty: Medium
5+
*
6+
* There exists an infinitely large two-dimensional grid of uncolored unit cells.
7+
* You are given a positive integer n, indicating that you must do the following
8+
* routine for n minutes:
9+
* - At the first minute, color any arbitrary unit cell blue.
10+
* - Every minute thereafter, color blue every uncolored cell that touches a blue cell.
11+
*
12+
* Below is a pictorial representation of the state of the grid after minutes 1, 2, and 3.
13+
*/
14+
15+
/**
16+
* @param {number} n
17+
* @return {number}
18+
*/
19+
var coloredCells = function(n) {
20+
return 1 + 2 * n * (n - 1);
21+
};

0 commit comments

Comments
 (0)