FunctionRacerProblemsRace

Majority Element II

EasyHash mapsPython, JavaScript, TypeScript, Java, C++

Return every value that appears more than len(nums) // 3 times in nums, sorted in increasing order. The answer may be an empty list.

Example 1

nums [3,2,3]
returns [3]

len // 3 = 1; 3 appears twice, 2 once.

Example 2

nums [1,2,3,4]
returns []

Each appears once, which is not more than 1.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Hash maps problems