Skip to content

Commit 62106d7

Browse files
del comments
1 parent 705b312 commit 62106d7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

contest/src/main/java/com/github/contest/hashTable/HashTableAlternativeSolution.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ fun countGoodAlternativeSolution(nums: IntArray, k: Int): Long {
6060
val freq = mutableMapOf<Int, Int>()
6161

6262
for (right in nums.indices) {
63-
// Update the frequency of the current element
63+
6464
val num = nums[right]
6565
val currentFreq = freq.getOrDefault(num, 0)
66-
// Each existing occurrence creates new pairs
66+
6767
totalPairs += currentFreq
6868
freq[num] = currentFreq + 1
6969

70-
// While the window has enough pairs, try to shrink from the left
70+
7171
while (totalPairs >= k) {
7272
val leftNum = nums[left]
73-
// Before removing, reduce the pairs count
73+
7474
totalPairs -= freq[leftNum]!! - 1
7575
freq[leftNum] = freq[leftNum]!! - 1
7676
if (freq[leftNum] == 0) {
@@ -79,7 +79,7 @@ fun countGoodAlternativeSolution(nums: IntArray, k: Int): Long {
7979
left++
8080
}
8181

82-
// All subarrays ending at right with start <= left-1 are good
82+
8383
count += left
8484
}
8585

0 commit comments

Comments
 (0)