1233. Remove Sub-Folders from the Filesystem Medium
1/**
2 * [1233] Remove Sub-Folders from the Filesystem
3 *
4 * Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order.
5 * If a folder[i] is located within another folder[j], it is called a sub-folder of it.
6 * The format of a path is one or more concatenated strings of the form: '/' followed by one or more lowercase English letters.
7 *
8 * For example, "/leetcode" and "/leetcode/problems" are valid paths while an empty string and "/" are not.
9 *
10 *
11 * Example 1:
12 *
13 * Input: folder = ["/a","/a/b","/c/d","/c/d/e","/c/f"]
14 * Output: ["/a","/c/d","/c/f"]
15 * Explanation: Folders "/a/b" is a subfolder of "/a" and "/c/d/e" is inside of folder "/c/d" in our filesystem.
16 *
17 * Example 2:
18 *
19 * Input: folder = ["/a","/a/b/c","/a/b/d"]
20 * Output: ["/a"]
21 * Explanation: Folders "/a/b/c" and "/a/b/d" will be removed because they are subfolders of "/a".
22 *
23 * Example 3:
24 *
25 * Input: folder = ["/a/b/c","/a/b/ca","/a/b/d"]
26 * Output: ["/a/b/c","/a/b/ca","/a/b/d"]
27 *
28 *
29 * Constraints:
30 *
31 * 1 <= folder.length <= 4 * 10^4
32 * 2 <= folder[i].length <= 100
33 * folder[i] contains only lowercase letters and '/'.
34 * folder[i] always starts with the character '/'.
35 * Each folder name is unique.
36 *
37 */
38pub struct Solution {}
39
40// problem: https://leetcode.com/problems/remove-sub-folders-from-the-filesystem/
41// discuss: https://leetcode.com/problems/remove-sub-folders-from-the-filesystem/discuss/?currentPage=1&orderBy=most_votes&query=
42
43// submission codes start here
44
45impl Solution {
46 pub fn remove_subfolders(folder: Vec<String>) -> Vec<String> {
47 vec![]
48 }
49}
50
51// submission codes end
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56
57 #[test]
58 fn test_1233() {
59 }
60}
61
Back
© 2025 bowen.ge All Rights Reserved.