Facebook || Phone Screening || Unexpected files API question

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-08-07Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: e3, e4
Interview Stage: Phone Screening
Location: unknown
Year: unknown

Original Post Content:

Question:
Add two arbitrary large integers stored in two separate files and write the answer to the output file. Numbers are stored in binary representation in the little endian byte order.

Input:
/tmp/input-file-1
/tmp/input-file-2

Output:
/tmp/output-file

While this is a common variant of the Add Two numbers problem, I was unable to solve it properly since I didn't remember Java File APIs. While the interviewer did give me a hint after some time about which class to use, I didn't remember the method signatures for reading and writing streams.

Comments