One operator apart.
transcript
Two searches in one lesson. Lower bound and upper bound. They look like two algorithms. They are one search. Learn one, and you get both.
Both keep a window, lo to hi. Both check the middle. Both move lo past, or keep hi. Only one test differs. So write the loop once.
The lower bound asks: is it below x? Equal values are not below x. So lo stops in front of them. The upper bound asks: is it at most x? Equal values pass that test. So lo moves past them.
Take the amount four. The lower bound is one. The upper bound is four. The block between them is the fours.
A missing value makes both bounds equal. An empty list makes both bounds zero. Every value equal gives zero and n. Same code, same rule, no special cases.
Change less than to at most. Full breakdown in the lecture.