FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm/Week_01/id_126/LeetCode_24_126.java at master · feixiangcode/algorithm · GitHub
feixiangcode
/
algorithm
Public
forked from
algorithm001/algorithm
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm
/
Week_01
/
id_126
/
LeetCode_24_126.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (24 loc) · 626 Bytes
Breadcrumbs
algorithm
/
Week_01
/
id_126
/
LeetCode_24_126.java
Copy path
File metadata and controls
27 lines (24 loc) · 626 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
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class
Solution
{
public
ListNode
swapPairs
(
ListNode
head
) {
//判断当前值和下一个值是否为空
//不为空 交换
//为空 不动
if
(
head
==
null
||
head
.
next
==
null
){
return
head
;
}
ListNode
listNode
=
new
ListNode
(
0
);
listNode
.
val
=
head
.
val
;
listNode
.
next
=
swapPairs
(
head
.
next
.
next
);
head
=
head
.
next
;
head
.
next
=
listNode
;
return
head
;
}
}
Back
|
FazBrowse Home
|
New Git URL