71. Simplify Path

Practice Simplify Path for free on NudgeCode: Medium, Stack pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Given an absolute Unix-style file path (starting with /), return its simplified canonical form.

The result starts with a single /, separates names with one /, and has no trailing / (except the root itself, "/").

Example

path = "/a/./b/../../c/"  ->  "/c"

Constraints