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

Commitaa783df

Browse files
authored
Merge pull requestneetcode-gh#1419 from imevanc/Create-876-Middle-Of-The-Linked-List.js
Create: 876-Middle-Of-The-Linked-List.js
2 parents152cbea +f6e9d17 commitaa783df

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* https://leetcode.com/problems/middle-of-the-linked-list/
3+
* Definition for singly-linked list.
4+
* function ListNode(val, next) {
5+
* this.val = (val===undefined ? 0 : val)
6+
* this.next = (next===undefined ? null : next)
7+
* }
8+
*/
9+
/**
10+
*@param {ListNode} head
11+
*@return {ListNode}
12+
*/
13+
varmiddleNode=function(head){
14+
letfirst=head;
15+
letsecond=head;
16+
while(second!=null&&second.next!=null){
17+
first=first.next;
18+
second=second.next.next;
19+
}
20+
returnfirst;
21+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp