Maximum Number in a Large File
Problem statement
A very large text file contains one signed integer per line. Return the maximum integer in the file.
The practice runner supplies the parsed lines as an array numbers. Your algorithm should use constant auxiliary space so the same logic can process 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.