deno.land / x / masx200_leetcode_test@10.6.5 / middle-of-the-linked-list / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { ListNode } from "../reverse-linked-list/ListNode.ts";
export default function middleNode(head: ListNode | null): ListNode | null { if (!head) return head; if (!head.next) return head; let slow: null | ListNode = head; let fast: null | ListNode = head; while (fast && fast.next && slow) { slow = slow.next; fast = fast.next.next; } return slow;}
masx200_leetcode_test

Version Info

Tagged at
a year ago