For the corner case in Simplify Path


  • 3
    R

    Input: "/..."
    Output: "/"
    Expected: "/..."

    The "/..." is a legal path command ? I test it on my mac, but it returns

    -bash: cd: /...: No such file or directory


  • 4
    M

    '...' is a valid name for directory.
    You can try the following under bash:

    mkdir ...
    cd ...
    

  • 0
    S

    I tried, and it says:

    -bash: cd: ...: No such file or directory


  • 0
    M

    did you create that directory by mkdir first?


  • 0
    S

    No, After I tried
    mkdir ...
    cd ...
    It works!
    Can you explain a little about what does that mean?
    What my understand is it creates a file named "..." and it doesn't exist there, contradict.


  • 0
    M

    Yes it creates a directory called .... It is there once you create it. However you probably cannot see it from ls, because any file/directory starts with . is automatically considered as a hidden file/directory. You should be able to see it if you try ls -a.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.