Leetcode Problem 1233. Remove Sub-Folders from the Filesystem
1233. Remove Sub-Folders from the Filesystem
Leetcode Solutions
Sort and Check Subfolder Approach
Sort the list of folder paths.
Initialize an empty list to store the result.
Iterate through the sorted list of folders.
a. For the first folder, add it to the result list.
b. For each subsequent folder, check if it starts with the path of the last folder in the result list followed by a '/'.
c. If it does not, add the folder to the result list as it is not a subfolder.