Problems178
Search for a command to run...
First index whose value is not less than x
Try your own input
Change the array and replay the algorithm from step one.
Current step
Lower bound of 2: the index of the first element that is not less than 2. Scanning left to right, the first hit is that index.
Brute Force
1function lowerBound(nums, x) {2 const n = nums.length;//x: 2n: 4ans: —3 for (let i = 0; i < n; i++) {4 // First element not less than x5 if (nums[i] >= x) {6 return i;7 }8 }9 // Every element is smaller10 return n;11}