문제 링크 : Find the K-Beauty of a Number
/**
* @param {number} num
* @param {number} k
* @return {number}
*/
var divisorSubstrings = function(num, k) {
let count = 0
const strNum = num+''
for(let i =0; i<=strNum.length-k; i++) {
let tempNum = ''
for(let j=0; j<k; j++) {
tempNum += strNum[i+j]
}
if(num%parseInt(tempNum) === 0) count += 1
}
return count
};
/**
* @param {number} num
* @param {number} k
* @return {number}
*/
var divisorSubstrings = function(num, k) {
let nums = num.toString()
let l = 0, res = 0
for (let r = k; r <= nums.length; r++) {
let divisor = Number(nums.slice(l, r))
if (r - l === k && num % divisor === 0) res++
l++
}
return res
};