mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	add scripts and problemset
This commit is contained in:
		
							
								
								
									
										44
									
								
								算法题/remove-sub-folders-from-the-filesystem.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								算法题/remove-sub-folders-from-the-filesystem.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
<p>Given a list of folders <code>folder</code>, return <em>the folders after removing all <strong>sub-folders</strong> in those folders</em>. You may return the answer in <strong>any order</strong>.</p>
 | 
			
		||||
 | 
			
		||||
<p>If a <code>folder[i]</code> is located within another <code>folder[j]</code>, it is called a <strong>sub-folder</strong> of it.</p>
 | 
			
		||||
 | 
			
		||||
<p>The format of a path is one or more concatenated strings of the form: <code>'/'</code> followed by one or more lowercase English letters.</p>
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
	<li>For example, <code>"/leetcode"</code> and <code>"/leetcode/problems"</code> are valid paths while an empty string and <code>"/"</code> are not.</li>
 | 
			
		||||
</ul>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Example 1:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> folder = ["/a","/a/b","/c/d","/c/d/e","/c/f"]
 | 
			
		||||
<strong>Output:</strong> ["/a","/c/d","/c/f"]
 | 
			
		||||
<strong>Explanation:</strong> Folders "/a/b" is a subfolder of "/a" and "/c/d/e" is inside of folder "/c/d" in our filesystem.
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 2:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> folder = ["/a","/a/b/c","/a/b/d"]
 | 
			
		||||
<strong>Output:</strong> ["/a"]
 | 
			
		||||
<strong>Explanation:</strong> Folders "/a/b/c" and "/a/b/d" will be removed because they are subfolders of "/a".
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 3:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> folder = ["/a/b/c","/a/b/ca","/a/b/d"]
 | 
			
		||||
<strong>Output:</strong> ["/a/b/c","/a/b/ca","/a/b/d"]
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Constraints:</strong></p>
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
	<li><code>1 <= folder.length <= 4 * 10<sup>4</sup></code></li>
 | 
			
		||||
	<li><code>2 <= folder[i].length <= 100</code></li>
 | 
			
		||||
	<li><code>folder[i]</code> contains only lowercase letters and <code>'/'</code>.</li>
 | 
			
		||||
	<li><code>folder[i]</code> always starts with the character <code>'/'</code>.</li>
 | 
			
		||||
	<li>Each folder name is <strong>unique</strong>.</li>
 | 
			
		||||
</ul>
 | 
			
		||||
		Reference in New Issue
	
	Block a user