Skip to content

Commit dbd6261

Browse files
committed
Runtime: 99 ms (Top 84.38%) | Memory: 67.2 MB (Top 74.81%)
1 parent bf8af41 commit dbd6261

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/algorithms/K/K Divisible Elements Subarrays/K Divisible Elements Subarrays.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
// Runtime: 99 ms (Top 84.38%) | Memory: 67.2 MB (Top 74.81%)
12
class Solution {
23
public int countDistinct(int[] nums, int k, int p) {
34
int n = nums.length;
4-
// we are storing hashcode for all the substrings so that we can compare them faster.
5-
// main goal is to avoid entire sub array comparision using hashcode.
6-
Set<Long> ways = new HashSet<>();
5+
// we are storing hashcode for all the substrings so that we can compare them faster.
6+
// main goal is to avoid entire sub array comparision using hashcode.
7+
Set<Long> ways = new HashSet<>();
78
for(int i = 0; i < n; i++) {
89
int cnt = 0;
910
long hc = 1; // this is the running hashcode for sub array [i...j]
@@ -18,4 +19,4 @@ public int countDistinct(int[] nums, int k, int p) {
1819
}
1920
return ways.size();
2021
}
21-
}
22+
}

0 commit comments

Comments
 (0)