FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
coding-Interview/RemoveLinkedListElements.java at master · arjunmullick/coding-Interview · GitHub
arjunmullick
/
coding-Interview
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
3
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
coding-Interview
/
RemoveLinkedListElements.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (29 loc) · 820 Bytes
Breadcrumbs
coding-Interview
/
RemoveLinkedListElements.java
Copy path
File metadata and controls
37 lines (29 loc) · 820 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package
com
.
leetcode
;
public
class
RemoveLinkedListElements
{
//https://leetcode.com/problems/remove-linked-list-elements/
class
Solution
{
public
ListNode
removeElements
(
ListNode
head
,
int
val
) {
ListNode
start
=
new
ListNode
(
0
);
start
.
next
=
head
;
ListNode
prev
=
start
;
while
(
head
!=
null
){
if
(
head
.
val
==
val
){
prev
.
next
=
head
.
next
;
}
else
{
//important
prev
=
head
;
}
head
=
head
.
next
;
}
return
start
.
next
;
}
}
// * Definition for singly-linked list.
class
ListNode
{
int
val
;
ListNode
next
;
ListNode
(
int
x
) {
val
=
x
;
next
=
null
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL