From 37cbcaeac27b3a644526610ea91d52e02ef16d2d Mon Sep 17 00:00:00 2001 From: Rakshit Parashar <34675136+rishu2403@users.noreply.github.com> Date: Wed, 19 Oct 2022 21:45:34 -0700 Subject: [PATCH] Update DetailedBinarySearch.md Remove duplicate line --- think_like_computer/DetailedBinarySearch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/think_like_computer/DetailedBinarySearch.md b/think_like_computer/DetailedBinarySearch.md index f715581..76e250a 100644 --- a/think_like_computer/DetailedBinarySearch.md +++ b/think_like_computer/DetailedBinarySearch.md @@ -302,7 +302,7 @@ When `nums [mid] == target`, do not return immediately, but increase the lower b **2. Why does it return `left-1` instead of` left`? And I think that since it is searching for the right border, it should return `right` only**. -Answer: First, the termination condition of the while loop is `left == right`, so` left` and `right` are the same. You have to embody the characteristics of the right side and return` right-1`.Answer: First, the termination condition of the while loop is `left == right`, so` left` and `right` are the same. You have to embody the characteristics of the right side and return` right-1`. +Answer: First, the termination condition of the while loop is `left == right`, so` left` and `right` are the same. You have to embody the characteristics of the right side and return` right-1`. As for why it should be reduced by one, this is a special point in the search for the right border. The key is to judge in this condition: -- GitLab