A release dashboard lists build numbers that passed QA, in no particular order and possibly with repeats, in builds.
Write longestRun(builds) that returns the length of the longest run of consecutive whole numbers (like 10, 11, 12, 13) that all appear in builds. Repeats count once. Return 0 for an empty list. Aim for O(n) time, without sorting.
Input: builds = [12,3,10,11,4,13,5] Output: 4
10, 11, 12, and 13 are all present: a run of 4.
Input: builds = [7,7,7] Output: 1
Repeats count once, so the run is just 7.
0 <= builds.length <= 10^5-10^9 <= builds[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 #24 Longest Run of Consecutive Build Numbers. 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.