Created
April 9, 2017 11:44
-
-
Save linnykoleh/604b0851eb7d675b2eb4acdca7bfab12 to your computer and use it in GitHub Desktop.
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 ListNode removeElements(ListNode head, int val) { | |
final ListNode fake = new ListNode(-1); | |
fake.next = head; | |
ListNode cur = fake; | |
while(cur.next != null){ | |
if(cur.next.val == val){ | |
cur.next = cur.next.next; | |
}else{ | |
cur = cur.next; | |
} | |
} | |
return fake.next; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment