As reported: Microsoft SWE II, Windows team (Hyderabad hiring drive, Oct 2025), round 1 (DSA): reduce a file path to its canonical form — e.g.
/home/foo/bar/./../../appbecomes/home/app; solved inO(N)time and space.
Given an absolute Unix-style path, return its canonical form:
.is the current directory;..goes up one level (staying at/if already at the root).- Multiple slashes count as one; any other name (including
...) is a directory name. - The result starts with a single
/, has single slashes between names, no trailing slash, and no.or...
This is LeetCode 71 — Simplify Path.
Example 1
path = "/home/foo/bar/./../../app" -> "/home/app"
Example 2
path = "/a/./b/../../c/" -> "/c"
Example 3
path = "/../" -> "/"
Constraints: 1 ≤ path.length ≤ 3000; letters, digits, '.', '/' and '_'; path is a valid absolute path.
Code runner format: one JSON value per line: path (LeetCode's test-case format). Implement simplifyPath(path); the harness prints the result.