MediumPro challengePythonJavaScriptTypeScript
Path Normalize
BackendPathsAlgorithms
Resolve . and .. segments in a POSIX path. Preserve leading /.
solve('/a/b/../c/./d') → '/a/c/d'.solve('a/b/../../c') → 'c'.
Going above root collapses to / (or empty for relative).
Sample tests
Test #1Mixed
Input: ["/a/b/../c/./d"]
Output: "/a/c/d"
Test #2Up twice in relative
Input: ["a/b/../../c"]
Output: "c"
Test #3Collapse double slash
Input: ["/a//b"]
Output: "/a/b"
Test #4Root only
Input: ["/"]
Output: "/"
Test #5Relative above start
Input: ["../../x"]
Output: "../../x"