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, new Path("/a/b/c/d").Cd("../x").CurrentPath should return "/a/b/c/x".

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

C# 5.0, .NET Framework 4.5
 
 


  •   Example case: System.NotImplementedException at Path.Cd(String newPath) in Path.cs:line 14
  •   Two times down: System.NotImplementedException at Path.Cd(String newPath) in Path.cs:line 14
  •   Three times up: System.NotImplementedException at Path.Cd(String newPath) in Path.cs:line 14
  •   Complex paths: System.NotImplementedException at Path.Cd(String newPath) in Path.cs:line 14