45 min phone screen Interview.
Q1. 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 gonna be the same just need to track of the indices of the decimal and add it to my final string whichever index takes priority. Did not get time to implement it.
For library question.. I told I would need to throw exceptions when I see a non-numeric or a special character.
Q2. Random pick weight variant with city name and population.
I got stuck on this a little becuase this question is very vaguely put. When the interviewer pasted the question it said nothing what needs to be done. It . He said you will get a list of city with poputation and it should return cityPoluation/ totalPopulation . but once I figured out its 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 follow up. 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 the that is getting returned from the pick method.
The vibe I got from the interviewer was very skewed. He wasn't that friendly. I got a lot of help from leetcode community. Even though I will get a reject but wanted to help other so posting my detailed experience here. Best of luck all.