Remove Linked List Elements
Updated
Problem statement
Given the head of a singly linked list and an integer val, remove every node whose value equals val.
Return the head of the remaining list. Reuse the nodes that are not removed.
Function
removeElements(head: ListNode, val: int) → ListNodeExamples
Example 1
head = [1,2,6,3,4,5,6]val = 6return = [1,2,3,4,5]Removed
Moved or new
Both nodes containing 6 are removed.
Example 2
head = []val = 1return = []An empty list stays empty.
Example 3
head = [7,7,7,7]val = 7return = []Removing every node yields an empty list.
Constraints
- The list contains between
0and100000nodes. -1000000000 <= Node.val, val <= 1000000000.
More Bloomberg LP Phone Screen questions
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Merge Two Sorted ListsLinkedIn · PHONE SCREENLinkedIn interview questions
- Reverse a Linked ListCisco · PHONE SCREENCisco interview questions
- Reverse a Linked ListApple · PHONE SCREENApple interview questions
- Reverse a Singly Linked ListChubb · PHONE SCREENChubb interview questions
- Reverse a Singly Linked ListAdobe · PHONE SCREENAdobe interview questions
- Reverse a Singly Linked ListExpedia · PHONE SCREEN · ONSITE INTERVIEWExpedia interview questions
- Merge Two Sorted Linked ListsNutanix · PHONE SCREENNutanix interview questions
- Reverse a Singly Linked ListSuperhuman · PHONE SCREENSuperhuman interview questions
- Convert a Sorted Linked List to a Balanced BSTMeta · PHONE SCREENMeta interview questions
- Merge K Sorted Linked ListsBharatPe · PHONE SCREEN
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)