You are viewing a single comment's thread. Return to all comments →
O(n) solution using a stack:
def gamingArray(arr): stack=[arr[0]] for a in arr: if a != stack[-1]: if a > stack[-1]: stack.append(a) return "BOB" if len(stack) % 2 == 1 else "ANDY"
Seems like cookies are disabled on this browser, please enable them to open this website
Gaming Array 1
You are viewing a single comment's thread. Return to all comments →
O(n) solution using a stack: