Step 1: Start with candidate = 2 (first element), count = 1
candidate=2, count=1, array=[2, 2, 1, 1, 1, 2, 2]
Why: We pick the first element as a starting candidate
Step 2: Look at next element 2, same as candidate, increment count to 2
candidate=2, count=2, array=[2, 2, 1, 1, 1, 2, 2]
Why: Same number increases confidence in candidate
Step 3: Next element 1 differs, decrement count to 1
candidate=2, count=1, array=[2, 2, 1, 1, 1, 2, 2]
Why: Different number cancels one occurrence of candidate
Step 4: Next element 1 differs, decrement count to 0
candidate=2, count=0, array=[2, 2, 1, 1, 1, 2, 2]
Why: Count zero means candidate lost support, need new candidate
Step 5: Count is zero, pick new candidate = 1, count = 1
candidate=1, count=1, array=[2, 2, 1, 1, 1, 2, 2]
Why: Reset candidate to current element
Step 6: Next element 1 same as candidate, increment count to 2
candidate=1, count=2, array=[2, 2, 1, 1, 1, 2, 2]
Why: Same number increases count
Step 7: Next element 2 differs, decrement count to 1
candidate=1, count=1, array=[2, 2, 1, 1, 1, 2, 2]
Why: Different number cancels one occurrence of candidate
Step 8: Next element 2 differs, decrement count to 0
candidate=1, count=0, array=[2, 2, 1, 1, 1, 2, 2]
Why: Count zero means candidate lost support, need new candidate
Step 9: Count is zero, pick new candidate = 2, count = 1
candidate=2, count=1, array=[2, 2, 1, 1, 1, 2, 2]
Why: Reset candidate to current element
Result: Final candidate=2 with count>0, majority element is 2