49. search last index with Binary Search(possible duplicate array)

JavaScriptAlgorithm

easy  - accepted / - tried

This is a variation of 37. implement Binary Search (unique).

Your are given a sorted ascending array of number, but might have duplicates, you are asked to return the last index of a target number.

If not found return -1.

note

Please don't use Array.prototype.lastIndexOf(), it is not our goal.

Let's try to solve this problem within 10 minutes.

Discuss(30)