We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7a2917e commit 64dd4efCopy full SHA for 64dd4ef
992-subarrays-with-k-different-integers.js
@@ -7,7 +7,7 @@ const subarraysWithKDistinct = function(A, K) {
7
let res = 0
8
let prefix = 0
9
const m = new Array(A.length + 1).fill(0)
10
- for (let i = 0, j = 0, cnt = 0; i < A.length; i++) {
+ for (let i = 0, j = 0, cnt = 0, len = A.length; i < len; i++) {
11
if (m[A[i]]++ === 0) cnt++
12
if (cnt > K) {
13
m[A[j++]]--
0 commit comments