Approach Explanation o(〃^▽^〃)o
- I used Boyer–Moore Voting to find a possible majority element.
- If the current number matched the candidate, I increased the count, otherwise, I decreased it.
- Reset when count = 0 → I picked a new candidate.
- Verification step → After one pass, I checked if the candidate actually appeared more than ⌊n/2⌋ times.
- If yes, return the candidate. Otherwise, return -1
Method Used: (⇢^▽^)⇢
- Boyer–Moore Voting Algorithm
- Verification step
- Efficient runtime
- Constant space

Top comments (0)