Back to problems

Majority Element

Algorithm · Meta · Easy

Given an integer array containing n items, determine its majority value. A majority value occurs strictly more than ⌊n / 2⌋ times. You can rely on the array having at least one entry and on a majority value being present. Create a function that returns this value. Example: Constraints: 1 <= n <= 5 * 10^4 -10^9 <= nums[i] <= 10^9 Example

Checking your access…