You are viewing a single comment's thread. Return to all comments →
Python solution O(n) time and O(k) space.
k represent best case scenario worse case will be O(n) where every chars is added to the dictionary.
def gameOfThrones(s): chars = {} for c in s: if c not in chars: chars[c] = 0 if chars[c] > 0: chars[c] -= 1 else: chars[c] += 1 if sum(chars.values()) <= 1: return "YES" return "NO"
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Thrones - I
You are viewing a single comment's thread. Return to all comments →
Python solution O(n) time and O(k) space.
k represent best case scenario worse case will be O(n) where every chars is added to the dictionary.