Lecture
Coding Quiz - Remove the Smallest Number
In this coding quiz, you are tasked with writing a function that removes the smallest number from a given list of integers.
You will receive a list of integers from the user, find the smallest number in this list, remove it, and return the modified list.
If the list is empty or all elements need to be removed, return [-1].
For example, if the given list is [4, 3, 2, 1], you should remove the smallest number, 1, and return [4, 3, 2].
If the list is [10] or an empty list [], return [-1].
Write Code
def solution(arr): # Write your code here return
Constraints
-
The input list will contain only integers.
-
The list may be empty, or all elements may need to be removed.
Example Input and Output
-
Input:
[4, 3, 2, 1] -
Output:
[4, 3, 2]
-
Input:
[10] -
Output:
[-1]
Previous lessonAnagram Checker - Problem SolutionNext lessonRemoving the Smallest Number - Problem Solution
Lessons in this chapter · Python Coding Quiz Practice
- 1. Coding Quiz - Palindrome Check
- 2. Checking for Palindrome Strings - Problem Solving
- 3. Coding Quiz - Find Unique Words
- 4. Finding Unique Words - Problem Solving
- 5. Coding Quiz - Caesar Cipher
- 6. Caesar Cipher - Problem Solving
- 7. Coding Quiz - Find Prime Numbers
- 8. Finding Primes - Problem Solving
- 9. Coding Quiz - Finding Indices for a Target Sum
- 10. Creating Target Value with Two-Sum - Problem Solution
- 11. Coding Quiz - Maximize Stock Trading Profit
- 12. Finding Maximum Profit - Solution Explanation
- 13. Coding Quiz - Detecting Anagrams
- 14. Anagram Checker - Problem Solution
- 15. Coding Quiz - Remove the Smallest Number
- 16. Removing the Smallest Number - Problem Solution
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help