Problem
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 named x (it always exists).
After all the operations, return the minimum number of moves needed to get back to the main folder.
Example 1
- Input
- logs = ["d1/", "d2/", "../", "d21/", "./"]
- Output
- 2
Example 2
- Input
- logs = ["d1/", "d2/", "./", "d3/", "../", "d31/"]
- Output
- 3
Example 3
- Input
- logs = ["d1/", "../", "../", "../"]
- Output
- 0
Constraints
1 <= logs.length <= 10^32 <= logs[i].length <= 10Folder names contain lowercase letters and digits.