The TransCompilator

Solved LeetCode program · 895 of 1,000

#1233 · Remove Sub-Folders from the Filesystem

Medium Array chunk-18.md

Original English source

The folders is a list of "/a", "/a/b", "/c/d", "/c/d/e", and "/c/f". The removed is a list of 5 zeros.
For every left from 0 to the last position of folders.
For every right from 0 to the last position of folders.
The parent is item left of folders. The current is item right of folders. The parentsize is the length of parent. The currentsize is the length of current.
If parentsize is less than currentsize.
The same is 1.
For every index from 0 to parentsize minus 1.
The first is character index of current. The second is character index of parent. If first is not second, set same to 0.
If index is parentsize minus 1 and same is 1.
The edge is character parentsize of current. If edge is "/", set item right of removed to 1.

The kept is an empty list of text.
For every spot from 0 to the last position of folders.
If item spot of removed is 0, Place item spot of folders into kept.

The line is empty text. Place "[" into line.
For every spot from 0 to the last position of kept.
If spot is more than 0, Place "," into line. Place "\"" into line. Place item spot of kept into line. Place "\"" into line.

Place "]" into line. Show line.

Open in Playground Browse all 1,000 problems

Expected stdout

["/a","/c/d","/c/f"]