Solution to Majority Element by LeetCode

9 Apr


Question Name: Majority Element

We can do it with a dictionary (O(N) time, O(N) space). For a better solution with O(N) time and O(1) space, we can remove pairs of different elements as many as possible, and the remaining unique element is the majority.

Leave a Reply

Your email address will not be published. Required fields are marked *