Skip to content

Commit e9ab17e

Browse files
committed
add remove ele from linkedlist
1 parent 1aa3025 commit e9ab17e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

remove-linked-list-elements/README.md

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Definition for singly-linked list.
3+
* public class ListNode {
4+
* int val;
5+
* ListNode next;
6+
* ListNode(int x) { val = x; }
7+
* }
8+
*/
9+
public class Solution {
10+
public ListNode removeElements(ListNode head, int val) {
11+
12+
if(head == null) return null;
13+
14+
if(head.val == val) return removeElements(head.next, val);
15+
16+
head.next = removeElements(head.next, val);
17+
18+
return head;
19+
}
20+
}

remove-linked-list-elements/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
layout: solution
3+
title: Remove Linked List Elements
4+
date: 2015-04-23 11:38:34+08:00
5+
leetcode_id: 203
6+
---
7+
{% include_relative README.md %}

0 commit comments

Comments
 (0)