#71
Simplify Path
specialist · 890 · lc medium +31 · 50.1% accepted · 6,509 likes · top 38%
Description
Transform an absolute Unix-style file path (which always starts with '/') into its simplified canonical form. Resolve '.' (stay in place), '..' (go up one level), and consecutive slashes. The result must start with '/', use exactly one slash between directory names, have no trailing slash unless it is the root, and contain no '.' or '..' components.
Code
1
2
3