The Java programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.
Choosing the right data structure to solve a problem can have huge implications on the performance of an application. Knowing when to use a specific data structure is one of the most important skills for a programmer.
The string data structure is used to represent text. It is one of the most commonly used data structures. Therefore, every programmer should be skilled at string manipulation.
Public questions (free plan) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.
Write a function that provides change directory (cd) function for an abstract file system.
- Root path is '/'.
- Path separator is '/'.
- Parent directory is addressable as "..".
- Directory names consist only of English alphabet letters (A-Z and a-z).
- The function will not be passed any invalid paths.
- Do not use built-in path-related functions.
Path path = new Path("/a/b/c/d"); path.cd('../x'); System.out.println(path.getPath());
should display '/a/b/c/x'.
- Example case: java.lang.UnsupportedOperationException at Path.cd(Path.java:13)
- Selecting child directories: java.lang.UnsupportedOperationException at Path.cd(Path.java:13)
- Selecting parent directories: java.lang.UnsupportedOperationException at Path.cd(Path.java:13)
- Selecting complex paths: java.lang.UnsupportedOperationException at Path.cd(Path.java:13)