mirror of
				https://git.wolves.top/wolves/leetcode.git
				synced 2025-11-04 17:26:32 +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