mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			821 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			821 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Given a circular linked list, implement an algorithm that returns the node at the beginning of the loop.</p>
 | 
						|
 | 
						|
<p>Circular linked list: A (corrupt) linked list in which a node's next pointer points to an earlier node, so as to make a loop in the linked list.</p>
 | 
						|
 | 
						|
<p><strong>Example 1: </strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input: </strong>head = [3,2,0,-4], pos = 1
 | 
						|
<strong>Output: </strong>tail connects to node index 1</pre>
 | 
						|
 | 
						|
<p><strong>Example 2: </strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input: </strong>head = [1,2], pos = 0
 | 
						|
<strong>Output: </strong>tail connects to node index 0</pre>
 | 
						|
 | 
						|
<p><strong>Example 3: </strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input: </strong>head = [1], pos = -1
 | 
						|
<strong>Output: </strong>no cycle</pre>
 | 
						|
 | 
						|
<p><strong>Follow Up: </strong><br />
 | 
						|
Can you solve it without using additional space?</p>
 |