Skip to content

Commit 67e3cd2

Browse files
committed
⚡ [876]
1 parent ae360ec commit 67e3cd2

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

876/my_solution.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @return {ListNode}
1111
*/
1212
const middleNode = (head) => {
13-
let s = 0, f = 0, sHead = head, fHead = head;
13+
let sHead = head, fHead = head;
1414
while (null !== fHead) {
1515
if (null === fHead.next) return sHead;
1616
sHead = sHead.next;

876/solution.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Definition for singly-linked list.
3+
* function ListNode(val, next) {
4+
* this.val = (val===undefined ? 0 : val)
5+
* this.next = (next===undefined ? null : next)
6+
* }
7+
*/
8+
/**
9+
* @param {ListNode} head
10+
* @return {ListNode}
11+
*/
12+
const middleNode = (head) => {
13+
let sHead = head, fHead = head;
14+
while (null !== fHead) {
15+
if (null === fHead.next) return sHead;
16+
sHead = sHead.next;
17+
fHead = fHead.next.next;
18+
if (null === fHead) return sHead;
19+
}
20+
};

0 commit comments

Comments
 (0)