Last active
April 7, 2023 01:30
-
-
Save toantd90/7c0a8564c577de97f5d0424dc5b576c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function upperBound(arr, start, end, value) { | |
while (start <= end) { | |
const mid = start + Math.floor((end - start) / 2); | |
if (arr[mid] > value) { | |
end = mid - 1; | |
} else { | |
start = mid + 1; | |
} | |
} | |
return end; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment