Vote Verification with Majority Check
Vote Verification with Majority Check
HardArrays0% accepted
An election commission in Mumbai is validating voting patterns across M polling booths. An anomaly is detected if any vote sequence of length K has a candidate receiving more than K/2 votes (forming a majority without consensus). Find all such anomalies.
Approach
Given an array of N vote records with booth IDs, find all subarrays of length K where one candidate appears more than K/2 times.
Input
N=8, K=3, votes=[1,1,2,2,3,1,1,2]
Output
[[0,2],[1,3],[2,4],[4,6],[5,7]]
More Arrays problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards