Given an array of integers nums, return the majority element.
The majority element is the element that appears more than n / 2 times, where n is the length of the array.
You may assume that the majority element always exists in the array.
nums = [3, 2, 3]3nums = [2, 2, 1, 1, 1, 2, 2]2nums = [1]11 <= nums.length <= 5 * 10^4-10^9 <= nums[i] <= 10^9The majority element always exists in the array.Run your code to see results
Use Cmd+Enter to run