Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions solution/0800-0899/0876.Middle of the Linked List/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,31 @@ class Solution {
}
```

### **TypeScript**

```ts
/**
* Definition for singly-linked list.
* class ListNode {
* val: number
* next: ListNode | null
* constructor(val?: number, next?: ListNode | null) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
* }
*/

function middleNode(head: ListNode | null): ListNode | null {
let fast = head, slow = head;
while (fast != null && fast.next != null) {
fast = fast.next.next;
slow = slow.next;
}
return slow;
};
```

### **...**

```
Expand Down
25 changes: 25 additions & 0 deletions solution/0800-0899/0876.Middle of the Linked List/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,31 @@ class Solution {
}
```

### **TypeScript**

```ts
/**
* Definition for singly-linked list.
* class ListNode {
* val: number
* next: ListNode | null
* constructor(val?: number, next?: ListNode | null) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
* }
*/

function middleNode(head: ListNode | null): ListNode | null {
let fast = head, slow = head;
while (fast != null && fast.next != null) {
fast = fast.next.next;
slow = slow.next;
}
return slow;
};
```

### **...**

```
Expand Down
20 changes: 20 additions & 0 deletions solution/0800-0899/0876.Middle of the Linked List/Solution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Definition for singly-linked list.
* class ListNode {
* val: number
* next: ListNode | null
* constructor(val?: number, next?: ListNode | null) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
* }
*/

function middleNode(head: ListNode | null): ListNode | null {
let fast = head, slow = head;
while (fast != null && fast.next != null) {
fast = fast.next.next;
slow = slow.next;
}
return slow;
};