mirror of
https://github.com/TheAlgorithms/Ruby
synced 2025-01-17 06:11:43 +01:00
Pass rubocop
This commit is contained in:
parent
00a3e61cfe
commit
e2a03f33c4
1 changed files with 6 additions and 9 deletions
|
@ -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
|
||||
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
|
||||
end
|
||||
|
||||
# returns -1 if search_item is not found in array
|
||||
return -1
|
||||
-1
|
||||
end
|
||||
|
||||
puts(double_linear_search([1, 5, 5, 10], 1))
|
||||
|
|
Loading…
Reference in a new issue