Remove Minimum Element from Linked List
EasyP3Coding
Remove the node with the minimum value from a singly linked list and return the head. If the minimum value occurs more than once, remove only the first node (closest to the head) that holds it. The empty list stays empty. A list node has val and next. The ListNode class is already defined for you.
Example 1
- Input
- head = [3,1,2]
- Output
- [3,2]
Example 2
- Input
- head = [1,2,3]
- Output
- [2,3]
Example 3
- Input
- head = [4,1,1]
- Output
- [4,1]
Constraints
- 0 <= number of nodes <= 1000
- -10^4 <= Node.val <= 10^4
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 10. ⌘Enter runs, ⌘⇧Enter submits.