Last active
February 26, 2021 10:29
-
-
Save lifeparticle/3299ce0373617e267202faa6fd9942b7 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
public static int lowerBound (int values[], int target) { | |
int left = 0; | |
int right = values.length - 1; | |
int mid; | |
if (values[right] < target) | |
return values.length; | |
while (right > left){ | |
mid = (left + right) / 2; | |
if (values[mid] < target) | |
left = mid + 1; | |
else | |
right = mid; | |
} | |
return left; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment