mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-01-13 02:38:37 +08:00
init
This commit is contained in:
33
23/11/Q876.h
Normal file
33
23/11/Q876.h
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// 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
|
||||
Reference in New Issue
Block a user