A developer profile shows an impact score. dependents[i] is how many other projects depend on the developer's package i. The impact score is the largest number h such that at least h of their packages each have at least h dependents.
Write impactScore(dependents) that returns that score. Aim for O(n) time.
Input: dependents = [3,0,6,1,5] Output: 3
Three packages (3, 6, 5) have at least 3 dependents each, but only two have at least 4.
Input: dependents = [1,3,1] Output: 1
Only one package has 2 or more dependents.
1 <= dependents.length <= 1000000 <= dependents[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 #204 Package Impact Score. 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.