Find the K-Beauty of a Number (Leetcode 2269)
Problem Link: https://leetcode.com/problems/find-the-k-beauty-of-a-number/
class Solution:
def divisorSubstrings(self, num: int, k: int) -> int:
s=str(num)
n=len(s)
i=0
j=0
ans=0
tempstring=''
while(j<n):
tempstring=tempstring+s[j]
if(j-i+1<k):
j+=1
elif(j-i+1==k):
tempnumber=int(tempstring)
if(tempnumber!=0):
if(num%tempnumber==0):
ans+=1
tempstring=tempstring[1:]
i+=1
j+=1
return ans
PreviousSubstrings of Size Three with Distinct Characters (Leetcode 1876)NextMaximum Average Subarray I (Leetcode 643)
Last updated