#K85527. Simplify Unix Path
Simplify Unix Path
Simplify Unix Path
Given an absolute Unix-style file path, simplify it to its canonical form.
The canonical path should adhere to the following rules:
- The path starts with a single slash '/'.
- Any two directories are separated by a single slash '/'.
- The path does not end with a trailing '/' (unless it is the root directory '/').
- The special directory "." means the current directory, so it can be ignored.
- The special directory ".." moves up one directory if possible.
- Multiple consecutive slashes are treated as a single slash.
For example, the canonical form of "/a//b////c/d//././/.." is "/a/b/c".
inputFormat
The input consists of a single line, which is a non-empty string representing an absolute Unix-style file path. The path starts with a '/' and may contain letters, digits, '.', '..', and additional '/' characters.
outputFormat
Output the canonical simplified path as a single line on standard output.
## sample/home/
/home