From e2a03f33c4e7ef662ede4323b4f33a886404b8b2 Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Sun, 20 Dec 2020 16:50:42 -0800 Subject: [PATCH] Pass rubocop --- searches/double_linear_search.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/searches/double_linear_search.rb b/searches/double_linear_search.rb index e8b63f3..e68b02f 100644 --- a/searches/double_linear_search.rb +++ b/searches/double_linear_search.rb @@ -5,18 +5,15 @@ def double_linear_search(array, search_item) end_ind = array.length - 1 while start_ind <= end_ind - if array[start_ind] == search_item - return start_ind - elsif array[end_ind] == search_item - return end_ind - else - start_ind += 1 - end_ind -= 1 - end + return start_ind if array[start_ind] == search_item + return end_ind if array[end_ind] == search_item + + start_ind += 1 + end_ind -= 1 end # returns -1 if search_item is not found in array - return -1 + -1 end puts(double_linear_search([1, 5, 5, 10], 1))