Crawler Log Folder
EasyStack
Decode it first. Clues, constraints, pattern and plan before any code.A file explorer logs every folder change as a string in logs. You start in the main folder. Each log is one of:
"../": move to the parent folder. If you are already in the main folder, stay where you are."./": stay in the current folder."x/": move into the child folder namedx(it always exists).
After all the operations, return the minimum number of moves needed to get back to the main folder.
logs = ["d1/", "d2/", "../", "d21/", "./"] → 2
logs = ["d1/", "d2/", "./", "d3/", "../", "d31/"] → 3
logs = ["d1/", "../", "../", "../"] → 0Constraints
1 <= logs.length <= 10^32 <= logs[i].length <= 10- Folder names contain lowercase letters and digits.