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.
Weighted Uniform Strings
Weighted Uniform Strings
Sort by
recency
|
768 Discussions
|
Please Login in order to post a comment
Java Solution using a Set O(n+q); n is the length of the string and q is the length of the queries list
Python 3
Simple C++ Solution, video here : https://youtu.be/xhpzPQBB9ts
Solution in Kotlin:
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