Skip to content

Commit 7d0dd97

Browse files
committed
Runtime: 3190 ms (Top 8.57%) | Memory: 86.8 MB (Top 45.72%)
1 parent 4e67263 commit 7d0dd97

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
// Runtime: 3190 ms (Top 8.57%) | Memory: 86.8 MB (Top 45.72%)
12
var countDistinct = function(nums, k, p) {
23
let ans = [];
3-
4+
45
let rec = (index,k,p,nums,ans,curr) => {
56
let val = nums[index];
67
let check = val%p;
78
let isdiv = false;
89
if(check == 0) isdiv=true;
9-
10+
1011
if(index == nums.length) {
1112
if(curr.length>0){
1213
ans.push(curr.join(","));
1314
}
1415
return;
1516
}
16-
17+
1718
//take conditions
1819
if(isdiv && k==0){
1920
ans.push(curr.join(","));
@@ -26,18 +27,17 @@ var countDistinct = function(nums, k, p) {
2627
rec(index+1,k,p,nums,ans,curr);
2728
curr.pop()
2829
}
29-
30-
30+
3131
//non take conditions
3232
if(curr.length == 0){
3333
rec(index+1,k,p,nums,ans,curr);
3434
} else {
3535
ans.push(curr.join(","));
3636
}
37-
37+
3838
}
3939
rec(0,k,p,nums,ans,[]);
4040
let set = new Set(ans);
41-
41+
4242
return set.size
43-
};
43+
};

0 commit comments

Comments
 (0)