Created
April 8, 2020 23:14
-
-
Save RP-3/1b9ec98abd1da258391a65083c6d4845 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Definition for singly-linked list. | |
* function ListNode(val) { | |
* this.val = val; | |
* this.next = null; | |
* } | |
*/ | |
/** | |
* @param {ListNode} head | |
* @return {ListNode} | |
*/ | |
var middleNode = function(head) { | |
let [fast, slow] = [head, head]; | |
while(fast && fast.next){ | |
slow = slow.next; | |
fast = fast.next.next; | |
} | |
return slow; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment