Middle of the Linked List
ID
876
Data Type
Linked List
Difficulty
Easy
Tags
Fast & Slow Pointers
Completed Date
May 9, 2024
Preference
💸😭 Poverty Tears
Given the
head
of a singly linked list, return the middle node of the linked list.If there are two middle nodes, return the second middle node.
Example 1:
![notion image](https://assets.leetcode.com/uploads/2021/07/23/lc-midlist1.jpg?t=3e10d276-22a1-484f-a780-f183040da793)
Example 2:
![notion image](https://assets.leetcode.com/uploads/2021/07/23/lc-midlist2.jpg?t=92c8dc7b-9a73-4b01-a710-b22ec658fea2)
Constraints:
- The number of nodes in the list is in the range
[1, 100]
.
1 <= Node.val <= 100
题解
快慢指针,没什么好说的,注意边界条件