Given a vector of integers nums, return the value that appears in it the most times.
If several values tie for the most appearances, return the one that shows up first in nums. nums has at least one number.
Example 1:
Input: nums = [1, 3, 2, 3, 1, 3] Output: 3 Explanation: 3 appears three times, 1 twice and 2 once.
Example 2:
Input: nums = [5, 2, 2, 5, 9] Output: 5 Explanation: 5 and 2 both appear twice. 5 shows up first (at index 0, while 2 first shows up at index 1), so the answer is 5.
Example 3:
Input: nums = [7] Output: 7 Explanation: The only value is also the most frequent one.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
