So here I am diving into this clever trick called BM majority voting that claims to find a majority element in just O(1) space. Sounds too good, right? Well… not exactly what you might think after digging deeper I started off with an obvious solution using HashMap and then began questioning why it's necessary for this fancy algorithm when we already have such efficient data structures! But as I continued exploring its ins-and outs (or lack thereof), the magic of BM majority voting slowly unraveled itself before my eyes I think you should join me on a little adventure to understand why it works, where it fails and most importantly…where in our coding projects does this gem actually belong? Let's share notes!
Source:
https://dev.to/yash1402_/boyer-moore-majority-voting-why-it-works-why-it-fails-and-where-it-actually-belongs-1ibn