Q876.h 583 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // Created by 李洋 on 2023/11/7.
  3. //
  4. #ifndef LEECODE_C_Q876_H
  5. #define LEECODE_C_Q876_H
  6. #include <vector>
  7. #include <stack>
  8. using namespace std;
  9. struct ListNode {
  10. int val;
  11. ListNode *next;
  12. ListNode() : val(0), next(nullptr) {}
  13. ListNode(int x) : val(x), next(nullptr) {}
  14. ListNode(int x, ListNode *next) : val(x), next(next) {}
  15. };
  16. ListNode *middleNode(ListNode *head) {
  17. ListNode *slow = head, *fast = head;
  18. while (fast && fast->next) {
  19. slow = slow->next;
  20. fast = fast->next->next;
  21. }
  22. return slow;
  23. }
  24. #endif //LEECODE_C_Q876_H
备用站点 当前处于降级运行的备用站点,仅供应急访问,数据和功能可能不是最新。