Skip to content

Commit 67dc0f0

Browse files
authored
Create Find the K-Beauty of a Number.java
1 parent 9f76b51 commit 67dc0f0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public int divisorSubstrings(int num, int k) {
3+
String numString = String.valueOf(num);
4+
int count = 0;
5+
for (int i = 0; i <= numString.length() - k; i++) {
6+
int substringNum = Integer.parseInt(numString.substring(i, i + k));
7+
if (substringNum != 0 && num % substringNum == 0) {
8+
count++;
9+
}
10+
}
11+
return count;
12+
}
13+
}

0 commit comments

Comments
 (0)