Skip to content

Commit 8488d9c

Browse files
committed
Solution as on 04-06-2022 06:40 am
1 parent e26f049 commit 8488d9c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// 2269.✅ Find the K-Beauty of a Number
2+
3+
class Solution
4+
{
5+
public:
6+
int divisorSubstrings(int num, int k)
7+
{
8+
string str = to_string(num);
9+
int i = 0, j = 0, n = str.length();
10+
int ind = 0;
11+
12+
while (j < n)
13+
{
14+
if (j - i + 1 < k)
15+
{
16+
++j;
17+
}
18+
else if (j - i + 1 == k)
19+
{
20+
string s = str.substr(i, k);
21+
int n = stoi(s);
22+
if (n != 0 && num % n == 0)
23+
++ind;
24+
25+
++i;
26+
++j;
27+
}
28+
}
29+
30+
return ind;
31+
}
32+
};

0 commit comments

Comments
 (0)