The basic traversal part was fine, but I fumbled the head removal case for a bit.
Start by clarifying edge cases (empty list, all nodes removed, removal at head) and then present an iterative solution using a dummy node to simplify head removal. Walk through the pointer manipulation step by step, emphasizing O(n) time and O(1) space, and test with a small example.
Pro tip: Mention that using a dummy node avoids special-casing the head, and explicitly discuss how you would test the solution with edge cases like removing the head or all nodes.
Ask if the list can be empty, if all nodes might be removed, and if the value can appear multiple times. Confirm return type and that the list is singly linked.
Decide between iterative and recursive. For interviews, iterative with a dummy node is usually preferred for O(1) space and simplicity.
Create a dummy node pointing to head, use a current pointer to traverse, and adjust next pointers to skip nodes with the target value. Return dummy.next.
State that time complexity is O(n) since each node is visited once, and space complexity is O(1) for the iterative approach.
Walk through a small example, including edge cases like removing the head, removing consecutive nodes, and removing all nodes.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.