Simplify Directory Path


Given a string A representing an absolute path for a file (Unix-style).

Return the string A after simplifying the absolute path.

Note:

  1. Absolute path always begin with ’/’ ( root directory ).

  2. Path will not have whitespace characters.



Input Format

The only argument given is string A.

Output Format

Return a string denoting the simplified absolue path for a file (Unix-style).

For Example

Input 1:
    A = "/home/"
Output 1:
    "/home"

Input 2:
    A = "/a/./b/../../c/"
Output 2:
    "/c"
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Simplify Directory Path on Interview Code Editor
Sign Up
to access hints and editorial solutions for Simplify Directory Path
Asked In:

Discussion


Loading...
Click here to start solving coding interview questions