Created
January 18, 2023 02:50
-
-
Save toantd90/a1191dcd0f40aceb00f6f1dbd9a80825 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 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