Skip to content

Commit c3340ac

Browse files
committed
Runtime: 0 ms (Top 100.00%) | Memory: 6 MB (Top 61.38%)
1 parent f80d980 commit c3340ac

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
1+
// Runtime: 0 ms (Top 100.00%) | Memory: 6 MB (Top 61.38%)
12
class Solution {
23
public:
34
int divisorSubstrings(int num, int k) {
45
string str = to_string(num);
56
int i = 0, j = 0, n = str.length();
67
int ind = 0;
7-
8+
89
while(j < n)
910
{
1011
if(j - i + 1 < k)
1112
{
12-
// increment j till we get the window size
13+
// increment j till we get the window size
1314
++j;
1415
}
1516
else if(j - i + 1 == k)
1617
{
17-
// on hiting the window size
18-
// extract window string and convert to int
19-
// check if it follows the given condition
18+
// on hiting the window size
19+
// extract window string and convert to int
20+
// check if it follows the given condition
2021
string s = str.substr(i,k);
2122
int n = stoi(s);
2223
if(n != 0 && num % n == 0 )
2324
++ind;
24-
25-
// shift the window by ++j;
26-
// remove previous calculation by ++i
25+
26+
// shift the window by ++j;
27+
// remove previous calculation by ++i
2728
++i;
2829
++j;
2930
}
30-
31+
3132
}
32-
33+
3334
return ind;
3435
}
35-
};
36+
};

0 commit comments

Comments
 (0)