You are viewing a single comment's thread. Return to all comments →
New to python here thats why the lengthy code:
def countSubstrings(s, queries): endresult = [] for i in range(len(queries)): left = queries[i][0] right = queries[i][1]+1 sub = s[left:right] a,r,k = '',[],[] if len(sub) == 1 or len(sub) == 0: endresult += [len(sub)] continue else: for i in sub: if i not in r: r += [i] #all unique letters added to list for i in range(len(sub)): for j in range(i,len(sub)): a += sub[j] r += [a] a = '' for i in range(len(sub)): for j in range(len(sub)-1,i+1,-1): a = sub[j] r += [a] a = '' for i in r: if i not in k: k += [i] endresult += [len(k)] return endresult
Seems like cookies are disabled on this browser, please enable them to open this website
How Many Substrings?
You are viewing a single comment's thread. Return to all comments →
New to python here thats why the lengthy code: