Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jackhowa/where-i-belong

Not the Linkin Park song, an algorithm and array problem. Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted.
https://github.com/jackhowa/where-i-belong

algorithm freecodecamp

Last synced: 21 days ago
JSON representation

Not the Linkin Park song, an algorithm and array problem. Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted.

Awesome Lists containing this project

README

        

# where-i-belong

Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted. The returned value should be a number.

For example, getIndexToIns([1,2,3,4], 1.5) should return 1 because it is greater than 1 (index 0), but less than 2 (index 1).

Likewise, getIndexToIns([20,3,5], 19) should return 2 because once the array has been sorted it will look like [3,5,20] and 19 is less than 20 (index 2) and greater than 5 (index 1).