java.lang.Object
g1201_1300.s1233_remove_sub_folders_from_the_filesystem.Solution

public class Solution extends Object
1233 - Remove Sub-Folders from the Filesystem.<p>Medium</p> <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>&quot;/leetcode&quot;</code> and <code>&quot;/leetcode/problems&quot;</code> are valid paths while an empty string and <code>&quot;/&quot;</code> are not.</li> </ul> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> folder = [&ldquo;/a&rdquo;,&ldquo;/a/b&rdquo;,&ldquo;/c/d&rdquo;,&ldquo;/c/d/e&rdquo;,&ldquo;/c/f&rdquo;]</p> <p><strong>Output:</strong> [&ldquo;/a&rdquo;,&ldquo;/c/d&rdquo;,&ldquo;/c/f&rdquo;]</p> <p><strong>Explanation:</strong> Folders &ldquo;/a/b&rdquo; is a subfolder of &ldquo;/a&rdquo; and &ldquo;/c/d/e&rdquo; is inside of folder &ldquo;/c/d&rdquo; in our filesystem.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> folder = [&ldquo;/a&rdquo;,&ldquo;/a/b/c&rdquo;,&ldquo;/a/b/d&rdquo;]</p> <p><strong>Output:</strong> [&ldquo;/a&rdquo;]</p> <p><strong>Explanation:</strong> Folders &ldquo;/a/b/c&rdquo; and &ldquo;/a/b/d&rdquo; will be removed because they are subfolders of &ldquo;/a&rdquo;.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> folder = [&ldquo;/a/b/c&rdquo;,&ldquo;/a/b/ca&rdquo;,&ldquo;/a/b/d&rdquo;]</p> <p><strong>Output:</strong> [&ldquo;/a/b/c&rdquo;,&ldquo;/a/b/ca&rdquo;,&ldquo;/a/b/d&rdquo;]</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>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details