Created
December 9, 2019 21:43
-
-
Save venelrene/0af3316cbb4c2ad127dc53e95bfa094d to your computer and use it in GitHub Desktop.
Given an array of integers, remove the smallest value. Do not mutate the original array/list. If there are multiple elements with the same value, remove the one with a lower index. If you get an empty array/list, return an empty array/list. Don't change the order of the elements that are lef
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def remove_smallest(numbers) | |
| return numbers if numbers.empty? | |
| numbers.dup.tap { |i| i.delete_at(numbers.index(numbers.min)) } | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment