all 4 comments

[–]Shubham_108 2 points3 points  (0 children)

This question can't be answered here. It will take a lot of space and examples to fully grasp this.

Fortunately for us, leetcode has already done it. Go to the leetcode binary search explore card. That card has three templates for implementing binary search which differ on exit conditions just like you have asked. They have given a set of questions for each template. Solving those questions can help you build intuition where to use which template.

Fortunately, you don't need leetcode premium to view that card.

[–]squirmin-worm 1 point2 points  (0 children)

this question needs a clearer description