Skip to content

Instantly share code, notes, and snippets.

@toantd90
Created January 18, 2023 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toantd90/a1191dcd0f40aceb00f6f1dbd9a80825 to your computer and use it in GitHub Desktop.
Save toantd90/a1191dcd0f40aceb00f6f1dbd9a80825 to your computer and use it in GitHub Desktop.
function lowerBound(arr, start, end, value) {
while (start < end) {
const mid = start + Math.floor((end - start) / 2)
if (arr[mid] < value) {
start = mid + 1
} else {
end = mid
}
}
return start
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment