Your question is Priority Queue Data Structure Task. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Solve a file/folder data structure coding task using a Priority Queue.
Asked in the Virtual Onsite stage. Second coding problem in the onsite interview involving storage, subfolders, and files.
Implement largest_files(root, k). root is a nested dictionary: folders have name, type: "folder", and children; files have name, type: "file", and nonnegative size. Return up to k files as [full_path, size], ordered by decreasing size, breaking ties by lexicographically ascending full path. Paths use / between names and include the root folder. Return [] when k is zero or the tree contains no files.
def largest_files(root, k):