Skip to content

Commit a9e4ad8

Browse files
committed
Add solution #2620
1 parent 7053058 commit a9e4ad8

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
2535|[Difference Between Element Sum and Digit Sum of an Array](./2535-difference-between-element-sum-and-digit-sum-of-an-array.js)|Easy|
364364
2618|[Check if Object Instance of Class](./2618-check-if-object-instance-of-class.js)|Medium|
365365
2619|[Array Prototype Last](./2619-array-prototype-last.js)|Easy|
366+
2620|[Counter](./2620-counter.js)|Easy|
366367
2629|[Function Composition](./2629-function-composition.js)|Easy|
367368
3392|[Count Subarrays of Length Three With a Condition](./3392-count-subarrays-of-length-three-with-a-condition.js)|Easy|
368369
3396|[Minimum Number of Operations to Make Elements in Array Distinct](./3396-minimum-number-of-operations-to-make-elements-in-array-distinct.js)|Easy|

solutions/2620-counter.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* 2620. Counter
3+
* https://leetcode.com/problems/counter/
4+
* Difficulty: Easy
5+
*
6+
* Given an integer n, return a counter function. This counter function initially
7+
* returns n and then returns 1 more than the previous value every subsequent
8+
* time it is called (n, n + 1, n + 2, etc).
9+
*/
10+
11+
/**
12+
* @param {number} n
13+
* @return {Function} counter
14+
*/
15+
var createCounter = function(n) {
16+
let count = n;
17+
return () => count++;
18+
};

0 commit comments

Comments
 (0)