You are viewing a single comment's thread. Return to all comments →
Anyone can help me for optimizing this code?
def solve(p, s, queries): bigNumber = str(s) count=0 result = [] for i in queries: count=0 q=i[1]+2-i[0] for j in range(i[0],i[1]+1): for k in range(1,q): if (int(bigNumber[j-1:j+k-1]))%p==0: count+=1 q-=1 result.append(count) return result
Seems like cookies are disabled on this browser, please enable them to open this website
Divisibility
You are viewing a single comment's thread. Return to all comments →
Anyone can help me for optimizing this code?