Given a full path to a file or directory in a Linux-like system, your task is to convert it into a standardized path.
In this system, a single dot .
points to the current directory, and two dots ..
mean moving one directory up. The simplified path should always start with a slash /
, with only one slash separating directory names. The path should not end with a slash unless it is the root directory. The result should be the shortest possible absolute path representing the same location.
Input: "/user/" Output: "/user" Explanation: The final path does not have a trailing slash after the directory name.
Input: "/../../" Output: "/" Explanation: Trying to go above root directory stays at root.
Input: "/user//docs/" Output: "/user/docs" Explanation: Multiple slashes are replaced by a single slash.
Input: "/x/./y/../z/" Output: "/x/z"
Input: "/x/../../y/../z//./" Output: "/z"
Input: "/x//y////z/w//././/.." Output: "/x/y/z"
.
, slashes /
, and underscores _
.