| 123456789101112131415161718192021222324252627282930313233 |
- //
- // Created by 李洋 on 2023/11/7.
- //
- #ifndef LEECODE_C_Q876_H
- #define LEECODE_C_Q876_H
- #include <vector>
- #include <stack>
- using namespace std;
- struct ListNode {
- int val;
- ListNode *next;
- ListNode() : val(0), next(nullptr) {}
- ListNode(int x) : val(x), next(nullptr) {}
- ListNode(int x, ListNode *next) : val(x), next(next) {}
- };
- ListNode *middleNode(ListNode *head) {
- ListNode *slow = head, *fast = head;
- while (fast && fast->next) {
- slow = slow->next;
- fast = fast->next->next;
- }
- return slow;
- }
- #endif //LEECODE_C_Q876_H
|