Where this number goes

A code exercise of about 15 minutes: read the statement, solve «Where this number goes» in the browser and get a review like in a real interview.

Code · 15 min
Loading…

Statement

Write searchInsert(sorted, target): sorted is in ascending order with no repeats. Return the index of target if it's there and, if not, the index where it would be inserted to keep the order. Without walking the whole list.