Skip to content

Instantly share code, notes, and snippets.

@rodocite
Created February 11, 2020 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodocite/e96db6685452958d65bc654a08adbce4 to your computer and use it in GitHub Desktop.
Save rodocite/e96db6685452958d65bc654a08adbce4 to your computer and use it in GitHub Desktop.
Delete all occurrences of a given key in a linked list
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