A package manager collects the build numbers of a dependency from many lockfiles into versions, sorted ascending. The same build number can appear many times.
Write dedupeVersions(versions) that removes the repeats in place so each build number appears once, in ascending order, and shortens the array to the kept items. Don't create a second array. The tests check versions after your function runs.
Input: versions = [2,2,3,5,5,5,8] Output: [2,3,5,8]
Each build number is kept once.
Input: versions = [1,4,6] Output: [1,4,6]
There are no repeats to remove.
0 <= versions.length <= 100000versions is sorted ascending.-10^6 <= versions[i] <= 10^6Run 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 #108 Dedupe a Sorted Version List. 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.