We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Few test cases are not cleared and have time limit exceeded error, can someone help me with this: (Python 3)
def weightedUniformStrings(s, queries):
u = []
count = 0
prev = None
for i in s:
if i == prev:
count +=1
else:
count = 1
u.append((ord(i)-96)*count)
prev = i
result = []
for i in queries:
if i in u:
result.append("Yes")
else:
result.append("No")
return result
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Weighted Uniform Strings
You are viewing a single comment's thread. Return to all comments →
Few test cases are not cleared and have time limit exceeded error, can someone help me with this: (Python 3)
def weightedUniformStrings(s, queries): u = [] count = 0 prev = None for i in s: if i == prev: count +=1 else: count = 1 u.append((ord(i)-96)*count) prev = i result = [] for i in queries: if i in u: result.append("Yes") else: result.append("No") return result