A notification bell logs its badge count after every update in counts. For each update, the analytics team wants the first later count that is strictly larger.
Write nextLarger(counts) that returns an array where position i holds the first value after index i that is greater than counts[i], or -1 if no later value is greater.
Input: counts = [2,1,5,3,4] Output: [5,5,-1,4,-1]
2 and 1 are first beaten by 5; 3 by 4; nothing beats 5 or 4.
Input: counts = [4,4,4] Output: [-1,-1,-1]
Equal counts are not larger.
0 <= counts.length <= 10^50 <= counts[i] <= 10^9Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #262 Next Larger Badge Count. 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.