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

Commit744b754

Browse files
committed
update: 24-2
1 parent075a57f commit744b754

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎src/swap-nodes-in-pairs/res.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,15 @@ function swapPairs(head: ListNode | null): ListNode | null {
3737
}
3838

3939
returnresult;
40-
};
40+
};
41+
42+
functionswapPairs2(head:ListNode|null):ListNode|null{
43+
if(!head?.next){
44+
returnhead;
45+
}
46+
47+
constresult=head.next;
48+
head.next=swapPairs(result.next);
49+
result.next=head;
50+
returnresult;
51+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp