Skip to content

Commit

Permalink
Time: 44 ms (90.31%) | Memory: 49.1 MB (9.66%) - LeetSync
Browse files Browse the repository at this point in the history
  • Loading branch information
ShatilKhan committed Mar 7, 2024
1 parent ed34b0e commit 8288577
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions 908-middle-of-the-linked-list/middle-of-the-linked-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Definition for singly-linked list.
* function ListNode(val, next) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
*/
/**
* @param {ListNode} head
* @return {ListNode}
*/
var middleNode = function(head) {
let slow = head;
let fast = head;
while(fast !== null && fast.next !== null){
slow = slow.next;
fast = fast.next.next;
}
return slow;
};

0 comments on commit 8288577

Please sign in to comment.