Facebook Phone Interview | Unexpected FileStream question
Anonymous User
1574

First question was a variant of 'Add two numbers' which I had solved before. Though I wasn't able to solve this one since I didn't remember Java File APIs. While the interviewer did give me a hint about which classes to use after some time, I didn't quite remember the method signatures and couldn't code it properly. i also got a few questions on how the Files API in Java works. These are the questions as I got them and don't have any typos. Even I was confused about the number being very large to fit in memory and an integer at the same time.


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

Second question was also easy. It was straight forward recursion with memoization. I was able to solve and code it quickly, but didn't have much time since the first question took so long.

Given a list of currency exchange rates from one country to another, find out the minimum number of conversions to exchange money from one country to another.

Input:

1. a list of currency exchange rates from one country to another, e.g.:
(countryA, countryB, 5),
(countryA, countryD, 10),
(countryB, countryD, 30),
2. a pair of from_country and to_country that we want to exchange currency, e.g.:
(countryA, countryD)

Output:
1. The minimum number of conversions that need to be done to convert money from from_country to to_country;
2. The final conversion rate to convert money from from_country to to_country according to output of 1;

DId not get selected though, because I did bad in the first question. So make sure you read up on File and Stream APIs to effectively solve them.

Comments (3)