Easy Solution to Find the Winner After Consecutive Wins
✅ IntuitionThe goal is to find the winner after k consecutive wins.
Since the array is circularly compared, the task reduces to finding the first element that w
### ✅ **Intuition**
The goal is to find the winner after `k` consecutive wins.  
- Since the array is circularly compared, the task reduces to **finding the first element** that wins `k` consecutive rounds or identifying the largest element if no one achieves `k` consecutive wins.  
- The **largest element** will eventually win if no one reaches `k` consecutive wins, making it the fallback winner.

---

### 🔥 **Approach**
- **Initialize** `maxVal` with the first element, representing the current winner.  
- Use a `count` variable to track the consecutive win streak.  
- Iterate through the array:
  - If the current element is larger than `maxVal`:  
    - It becomes the new winner.  
    - Reset the streak counter to `1`.  
  - If the current element is smaller or equal:  
    - Increase the streak count.  
- If any element wins `k` consecutive rounds, return it immediately.  
- If no element reaches `k` consecutive wins, return the **largest element** as the winner.

---

### ⏱️ **Complexity**
- **Time Complexity:** \(O(n)\) → One pass through the array, where \(n\) is the number of elements.  
- **Space Complexity:** \(O(1)\) → No additional space used.

# Code
```java []
class Solution {
    public int getWinner(int[] arr, int k) {
        int maxVal = arr[0];
        int count = 0;
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > maxVal) {
                maxVal = arr[i];
                count = 1;
            } else {
                count++;
            }
            if (count == k) {
                return maxVal;
            }
        }
        return maxVal;
    }
}

/*
class Solution {
    public int getWinner(int[] arr, int k) {
        ArrayList<Integer> res = new ArrayList<>();
        for (int num : arr) {
            res.add(num);
        }
        int count = 0;
        while (count < k) {
            if (res.get(0) > res.get(1)) {
                res.add(res.get(1));
                res.remove(1);
                count++;
            } else {
                res.add(res.get(0));
                res.remove(0);
                count = 1;
            }
        }
        return res.get(0);
    }
}
*/
```
['Array', 'Simulation', 'Java']