• + 0 comments

    Python3

    def gamingArray(arr):
        # Write your code here
        helper = sorted(arr, reverse=True)
        d = dict()
        for i in range(len(arr)):
            d[arr[i]] = i
        count = 0
        n = len(arr) - 1
        for maxVal in helper:
            if d[maxVal] <= n:
                n = d[maxVal] - 1
                count += 1
            if n < 0:
                break
        return 'BOB' if count % 2 == 1 else 'ANDY'