diff --git a/Find the Winner of an Array Game.py b/Find the Winner of an Array Game.py new file mode 100644 index 0000000..d51cfd3 --- /dev/null +++ b/Find the Winner of an Array Game.py @@ -0,0 +1,15 @@ +class Solution: + def getWinner(self, arr: List[int], k: int) -> int: + ans = arr[0] + wins = 0 + + i = 1 + while i < len(arr) and wins < k: + if arr[i] > ans: + ans = arr[i] + wins = 1 + else: + wins += 1 + i += 1 + + return ans