Maximum Number in a Large File
Updated
Problem statement
A very large text file contains one signed integer per line. Return the maximum integer in the file.
Your function gets the parsed lines as an array numbers. Use only a constant amount of extra memory, so the same logic could read a file as a stream without loading every line at once.
Function
maximumFileNumber(numbers: long[]) → longExamples
Example 1
numbers = [-5,7,2]return = 7Seven is larger than the other file values.
Example 2
numbers = [42]return = 42A one-line file returns its only number.
Example 3
numbers = [-9,-3,-12]return = -3The maximum can still be negative.
Constraints
1 <= numbers.length <= 1000000.- Every value fits in a signed 64-bit integer.
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
- Merchant Payout Reserve CalculatorStripe · PHONE SCREEN
- Price CheckBlue Origin · PHONE SCREEN
- Best Time to Buy and Sell StockMeta · PHONE SCREEN
- Lazy Filter over a GeneratorSquarepoint Capital · PHONE SCREEN
- Second Largest Distinct ElementAmazon · PHONE SCREEN
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREEN
- Search and Format ContactsAdyen · PHONE SCREEN
- Majority ElementByteDance · PHONE SCREEN
- Detect a Straight FlushTemu · PHONE SCREEN
- Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREEN