Search⌘ K

Problem Challenge: Folder Count

Understand how to solve the folder count challenge by implementing directoryInsert and directoryMatchCount methods using tries. This lesson helps you manage directory paths and retrieve folder counts accurately, enhancing your skills in file system management with trie data structures.

Problem statement

Implement two methods—directoryInsert and directoryMatchCount—for the provided directory paths.

The directoryInsert method takes the directory path as the input to create the given path.

The directoryMatchCount method returns the count of folders that are present from the start to the end of the path sequence.

Example 1

Sample input

directoryInsert("home/ben/files/movies")
directoryInsert("home/mike/profile")
directoryMatchCount("home/ben/files")
directoryInsert("home/arnold/profile")
directoryMatchCount("home/arnold/files")
...