LeetCode
var middleNode = function (head) { if (head.length % 2 === 0) { return head.slice(head.length / 2); } else { return head.slice(head.length / 2 + 1); } };
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; };
版權所有 © 2023 DOJO004