Available question text
You are given two APIs:
def list_dir(path: str) -> List[str]:
"""
Given a path, return the list of entries inside the directory.
Return [] or raise an exception if the path is not a directory.
"""
pass
def size_of(path: str) -> int:
"""
Given a file path, return its size in bytes.
Raise an exception or return -1 if it's a directory.
"""
pass
Implement the function:
def get_top_5_largest_files(path: str) -> List[Tuple[int, str]]:
"""
Return a list of the top 5 largest files in the directory tree rooted at path.
Each element is a tuple of (file_size, file_path).
"""
Constraints:
You can assume there are no symbolic links (no cycles).
Files and directories are represented as absolute paths (e.g., "/root/folder1/file.txt").
You must handle nested directories.
You can assume there are no permission issues and paths are accessible.
Related questions
Continue with questions that share topics or the same question type.
- Find Largest Value in Each Tree Row
Coding
- Find a Corresponding Node of a Binary Tree in a Clone of That Tree
Coding
- Find and remove duplicate files
Coding · File & Media Storage · Operating Systems
- Find Bottom Left Tree Value
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Google
Find Top 5 Largest Files in a Directory Tree
Reported Jun 21, 2025 · 1 source report
JUNIOR
Source snapshot: Nov 12, 2026
View source