FastPrepTop Ten Largest Files
Problems/Top Ten Largest Files

Top Ten Largest Files

Google logoGoogle● MediumNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for the ten largest files in a filesystem and discusses a heap plus other ways to walk the tree. Here you get parsed records of path and size, and we fix how ties break. Our version is about 84% the same as the reported question.

You are given parallel arrays paths and sizes, where each distinct file path has a non-negative byte size.

Return up to ten paths with the largest sizes, ordered from largest size to smallest. Break equal-size ties by lexicographically smaller path. When fewer than ten files are supplied, return all of them.

Design the selection so it can process a filesystem traversal as a stream without sorting every file.

Function

topTenLargestFiles(paths: String[], sizes: long[]) → String[]

Examples

Example 1

paths = ["/a","/b","/c"]sizes = [5,12,7]return = ["/b","/c","/a"]

All three files are returned from largest to smallest.

Example 2

paths = ["z","a","m"]sizes = [10,10,10]return = ["a","m","z"]

Equal sizes use lexicographic path order.

Example 3

paths = []sizes = []return = []

An empty traversal has no files.

Constraints

  • 0 <= paths.length = sizes.length <= 200000.
  • Paths are distinct, nonempty strings.
  • 0 <= sizes[i] <= 10^18.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Retrieve Vectors by Cosine SimilarityHarvey · ONSITE INTERVIEWHarvey interview questions
  • Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
  • Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
  • Meeting Rooms IISalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Top K Largest Values from a StreamThe D.E. Shaw Group · ONSITE INTERVIEWThe D.E. Shaw Group interview questions
  • Generate Complete Inputs for a Supplied ClassifierGeneral Motors · ONSITE INTERVIEW
  • Minimum Meeting Rooms Without a Sweep LineGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String[] topTenLargestFiles(String[] paths, long[] sizes) {
        // Write your code here.
    }
}
Checking account…