-
-
Save rodocite/e96db6685452958d65bc654a08adbce4 to your computer and use it in GitHub Desktop.
Delete all occurrences of a given key in a linked list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
public ListNode RemoveElements(ListNode h, int v) { | |
if (h == null) return null; | |
h.next = RemoveElements(h.next, v); | |
return h.val == v ? h.next : h; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment