Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Feb 12, 2025
1 parent fe90e56 commit 1b6f7b6
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions rust/binary-search/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ pub fn find(array: &[i32], key: i32) -> Option<usize> {

while left <= right {
middle = get_middle(left, right);
println!("left: {}, right: {}, middle: {}", left, right, middle);

// Special case
// Special case so that this function doesn't try to search below the index 0.
if middle == 0 {
if array[middle] == key {
return Some(middle)
Expand All @@ -20,7 +18,6 @@ pub fn find(array: &[i32], key: i32) -> Option<usize> {
}
}


if array[middle] == key {
return Some(middle)
} else if array[middle] < key {
Expand Down

0 comments on commit 1b6f7b6

Please sign in to comment.