Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita229b58

Browse files
refactor 21
1 parent6fdb918 commita229b58

File tree

1 file changed

+15
-14
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+15
-14
lines changed

‎src/main/java/com/fishercoder/solutions/_21.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@
99
* The new list should be made by splicing together the nodes of the first two lists.*/
1010

1111
publicclass_21 {
12-
13-
publicListNodemergeTwoLists(ListNodel1,ListNodel2) {
14-
if (l1 ==null) {
15-
returnl2;
16-
}
17-
if (l2 ==null) {
18-
returnl1;
19-
}
20-
if (l1.val <l2.val) {
21-
l1.next =mergeTwoLists(l1.next,l2);
22-
returnl1;
23-
}else {
24-
l2.next =mergeTwoLists(l1,l2.next);
25-
returnl2;
12+
publicstaticclassSolution1 {
13+
publicListNodemergeTwoLists(ListNodel1,ListNodel2) {
14+
if (l1 ==null) {
15+
returnl2;
16+
}
17+
if (l2 ==null) {
18+
returnl1;
19+
}
20+
if (l1.val <l2.val) {
21+
l1.next =mergeTwoLists(l1.next,l2);
22+
returnl1;
23+
}else {
24+
l2.next =mergeTwoLists(l1,l2.next);
25+
returnl2;
26+
}
2627
}
2728
}
2829

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp