Path


Data structures Strings Public

Hard  

30min


Write a function that provides change directory (cd) function for an abstract file system.

Notes:

  • Root path is '/'.
  • Path separator is '/'.
  • Parent directory is addressable as "..".
  • Directory names consist only of English alphabet letters (A-Z and a-z).

For example, Path("/a/b/c/d").cd("../x").getPath() should return "/a/b/c/x".

Note: Do not use built-in path-related functions.

 
 


  •   Example case: Exception
  •   Two times down: Exception
  •   Three times up: Exception
  •   Complex paths: Exception