Panda Guru LogoPanda
Guru

Meta E4/E5 Phone Screen | Probable Reject

Round 1

Questions:

  1. Add Strings
    Solved, but didn't get time to implement follow-up.
    Follow-up: Would this work for decimals? Consider this as a library method, what else would you add to it?
    Answer: I solved on paper saying that addition is going to be the same, just need to track the indices of the decimal and add it to my final string whichever index takes priority. Did not get time to implement it. For the library question, I told I would need to throw exceptions when I see a non-numeric or a special character.

  2. Random Pick Weight Variant with City Name and Population
    I got stuck on this a little because this question is very vaguely put. When the interviewer pasted the question, it said nothing about what needs to be done. He said you will get a list of cities with population and it should return cityPopulation / totalPopulation. But once I figured out it's a Random Pick weight variation, I was able to solve it with a class with 3 minutes remaining. Used List<Pair<String, Integer>> for mapping city and population to avoid mapping collisions. I gave a linear solution and also told him since prefixSum is increasing, binary search could bring it down to log(n).
    Follow-up: How would you test this class?
    Answer: Told him that I would need to mock the Random class to know in advance what sum value I would be getting and then assert that it is getting returned from the pick method.

Candidate's Approach

For the first question, I approached it by solving it on paper and discussing the handling of decimals and exceptions for non-numeric inputs. For the second question, I initially struggled due to the vague wording but eventually recognized it as a Random Pick weight variation and implemented a class to handle the logic. I also considered optimization through binary search.

Interviewer's Feedback

No feedback provided.