Phone Screen Uber
Company: Uber
Role: Software Engineer I, Software Engineer II
Interview Stage: Phone Screen
Original Post Content:
Given list of folders, print the path of a given folder from root. If there is no path to the root folder then return an empty string. Root level folders will have 0 as id. The structure of Folder is like this:
class Folder {
int id;
List<int> subfolders;
String name;
}
Ex:
list = [Folder(0, [7, 3], "abc"), Folder(0, [], "xyz"), Folder(3, [], "pqr"), Folder(8, [], "def"), Folder(7, [9], "ijk"), Folder(9, [], "lmn")]
printPath(9) = "abc" -> "ijk" -> "lmn" printPath(8) = "def"
Clarification: There can be multiple root level folders. All other folders have unique ids.
Note: printPath method may be called multiple times. Design your solution taking that into account
*/
Can someone help with the solution