A design review lets each reviewer vote for one mockup number. Mockups chosen by more than a third of the reviewers move on.
Write aboveAThird(nums) that returns every value appearing more than nums.length / 3 times, sorted ascending. Use O(1) extra memory.
Input: nums = [3,1,3,2,3,1,1] Output: [1,3]
1 and 3 each appear 3 times out of 7, more than 7 / 3.
Input: nums = [1,2,3] Output: []
Each value appears once, which is not more than 3 / 3 = 1.
0 <= nums.length <= 5 * 10^5-10^9 <= nums[i] <= 10^9Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #69 Votes Above a Third. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.