Simplify Path Problem
Simplify Path Problem — ExecCode Easy DSA Practice
Solve the Simplify Path problem on ExecCode. Free online easy DSA practice in Stack. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given an absolute path for a Unix-style file system, convert it to its simplified canonical path. A canonical path starts with '/', has no trailing '/', and resolves '.' (current directory) and '..' (parent directory) correctly. Multiple consecutive slashes are treated as a single slash. Return the simplified path string.
Examples
Input path = "/a/./b/../../c/d/"; Output "/c/d". Input path = "/home//foo/../bar/"; Output "/home/bar"
Constraints
1 ≤ path.length ≤ 3000 path consists of English letters, digits, ".", "/", "_".
Practice Simplify Path free on ExecCode. Browse DSA problems, topic map, and placement guides.