Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Lower Bound Lab
Searching
Problem shape
Intermediate
4
8
15
16
23
42
Core idea
Find the first index whose value is greater than or equal to a target.
Step 1 / 5
Problem shape
Searching Intermediate
Lower Bound
Welcome to the Lower Bound algorithm lab. Find the first index whose value is greater than or equal to a target. Use it when: Use for insertion position, frequency range, and monotonic predicate problems. The time complexity is O(log n), and the space complexity is O(1). The pseudocode is: low = 0, high = n while low < high mid = (low + high) / 2 if a[mid] < target low = mid + 1 else high = mid return low As you practice, track the state that changes and the condition that makes the algorithm stop.
Time
O(log n)
Space
O(1)
Pseudocode
low = 0, high = n
while low < high
mid = (low + high) / 2
if a[mid] < target low = mid + 1
else high = mid
return low 1.0x