Files
cpp-flashcards/org/study_deck_02/dsa/binary-search/lower-bound-vs-binary-search.org
T

12 lines
372 B
Org Mode
Raw Normal View History

#+ANKI_DECK: study_deck_02
* When to use lower_bound vs binary_search :cpp:binary-search:algorithm:retrieval::recognition:
:PROPERTIES:
:END:
** Front
When should you use ~std::lower_bound~ instead of ~std::binary_search~?
** Back
Use ~lower_bound~ when you need the *position/index* of the element.
Use ~binary_search~ when you only need to know *if it exists* (bool).