Step 1: Start with first element as candidate=2, count=1
Candidate=2, Count=1, Array=[2, 2, 1, 1, 1, 2, 2]
Why: We need a starting point to compare others.
Step 2: Next element is 2, same as candidate, increment count to 2
Candidate=2, Count=2, Array=[2, 2, 1, 1, 1, 2, 2]
Why: Same element increases confidence in candidate.
Step 3: Next element is 1, different from candidate, decrement count to 1
Candidate=2, Count=1, Array=[2, 2, 1, 1, 1, 2, 2]
Why: Different element cancels out one occurrence.
Step 4: Next element is 1, different from candidate, decrement count to 0
Candidate=2, Count=0, Array=[2, 2, 1, 1, 1, 2, 2]
Why: Count zero means candidate lost majority so far.
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 is 1, same as candidate, increment count to 2
Candidate=1, Count=2, Array=[2, 2, 1, 1, 1, 2, 2]
Why: Same element increases count.
Step 7: Next element is 2, different from candidate, decrement count to 1
Candidate=1, Count=1, Array=[2, 2, 1, 1, 1, 2, 2]
Why: Different element cancels out one occurrence.
Step 8: Next element is 2, different from candidate, decrement count to 0
Candidate=1, Count=0, Array=[2, 2, 1, 1, 1, 2, 2]
Why: Count zero means candidate lost majority so far.
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: Candidate=2 with final count=1
Majority element is 2