Path Existence

Solve an easy problem for inserting and checking whether a directory path exists in the file system using tries.

Problem statement

Implement two methods, directoryInsert and directoryExists, for provided directory paths.

The directoryInsert method takes the directory path as the input to create the given path. It returns true if a new folder is created; else, it returns false.

The directoryExists method returns true or false depending on whether the provided directory exists in the system.

Example 1

Sample input

Get hands-on with 1200+ tech skills courses.