Skip to content

Commit fa766e5

Browse files
committed
Time: 35 ms (96.12%), Space: 53.7 MB (95.10%) - LeetHub
1 parent 8e35228 commit fa766e5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public List<String> removeSubfolders(String[] folder) {
3+
Arrays.sort(folder);
4+
List<String> result = new ArrayList<>();
5+
6+
for(int i=0; i< folder.length; i++){
7+
String str = folder[i];
8+
result.add(str);
9+
String base = str+"/";
10+
11+
while(i+1< folder.length && folder[i+1].startsWith(base)){
12+
i++;
13+
}
14+
15+
}
16+
17+
return result;
18+
}
19+
}

0 commit comments

Comments
 (0)