Doubt in algorithm

When we encounter a number in array which is neither of the 2 majority elements we reduce count of both.
Suppose we get element 2 while traversing the array …then why don’t we reduce the count of element 1. It is reducing the majority of element 1.

Hey @vishakha_narang
Do a dry run on some small example
You will understand why we are not doing that :slight_smile:
We are keepingtrack of possible majority elements
So when 2nd element comes it does not mean majority of 1st element decrease .