Gaming Array 1

  • + 0 comments

    Python best solution

    If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions

    def gaming_array(arr):
        # Time complexity: O(n)
        # Space complexity (ignoring input): O(1)
        max_number = arr[0]
        turns = 0
        for number in arr:
            if number > max_number:
                max_number = number
                turns += 1
        if turns % 2 == 0:
            return "BOB"
        else:
            return "ANDY"