Medium

Quiz

#71 Simplify Path

APPROACH

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.

1 of 4
1:00

What is the optimal approach for this problem?