Question: Implement Lower Bound
Intution:
Time Complexity:
Space Complexity:
Solution:
public class Solution {
public static int lowerBound(int[] arr, int n, int x) {
int low = 0;
int high = n - 1;
int ans = n;
while (low <= high) {
int mid = low + (high - low) / 2;
if (arr[mid] < x) low = mid + 1;
else {
ans = mid;
high = mid - 1;
}
}
return ans;
}
}