Skip to main content
Crowdfunding
Python + AI for Geeks
Practice

Removing the Smallest Number - Problem Solution

Explore three ways to remove the smallest number from a list of integers.


Method 1
def solution(arr):
if not arr or len(arr) <= 1: # If list is empty or has only one element
return [-1] # Return [-1]
arr.remove(min(arr)) # Remove the smallest number
return arr

Usage Example

Input and Output Example
result = solution([4, 3, 2, 1])
print(result) # Output: [4, 3, 2]

result = solution([10])
print(result) # Output: [-1]

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.