From f20d72140ae7a57d25d88675799a0196c94ef426 Mon Sep 17 00:00:00 2001 From: Kavin <144545040+kavin81@users.noreply.github.com> Date: Thu, 2 Jan 2025 19:26:56 +0530 Subject: [PATCH] minor error in binary search instead of right = len(nums) -1 it's given as len(nums) --- articles/binary-search.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/articles/binary-search.md b/articles/binary-search.md index 5e88782ce..bfc872a8a 100644 --- a/articles/binary-search.md +++ b/articles/binary-search.md @@ -312,7 +312,7 @@ class Solution { ```python class Solution: def search(self, nums: List[int], target: int) -> int: - l, r = 0, len(nums) + l, r = 0, len(nums) -1 while l < r: m = l + ((r - l) // 2) @@ -455,7 +455,7 @@ class Solution { ```python class Solution: def search(self, nums: List[int], target: int) -> int: - l, r = 0, len(nums) + l, r = 0, len(nums) -1 while l < r: m = l + ((r - l) // 2) @@ -669,4 +669,4 @@ class Solution { ### Time & Space Complexity * Time complexity: $O(\log n)$ -* Space complexity: $O(1)$ \ No newline at end of file +* Space complexity: $O(1)$