Most frequent value

Write codeEasy12 min

Your task

Given a non-empty list of integers nums, return the value that appears most often. If two or more values tie for the highest frequency, return the smallest such value. The list has at least one element.

Examples

most_frequent(nums: list[int]) -> int
Example 1
Inputmost_frequent([1, 3, 1, 3, 2])
Output1