Created
April 20, 2022 08:18
-
-
Save danielchikaka/e68713a2a0d7357e0f8cf8ff60bcd637 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 left.
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): | |
# arr = numbers[:] | |
# if len(arr) > 0: | |
# arr.pop(arr.index(min(arr))) | |
# return arr | |
# else: | |
# return [] | |
def remove_smallest(numbers): | |
a = numbers[:] | |
if a: | |
a.remove(min(a)) | |
return a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment