Date: Feb 2020
Result: Rejection
Had a phone screen with a recruiter and then she scheduled for a technical screen.
The interviewer introduced himself and talked about his team after which i gave a brief intro.
He then he asked me to solve the following question.
Write a program to return the values that leads to null.
Example:
Input:
{
"Jon": "Smith",
"Adam": ["Jake", null, "Nancy"],
"Alex": {
"Muller": [null, "Sam"],
"Phil": null,
"Xav": ["Mike", "Tom"]
}
"Lex": null,
}
Output: ["Adam.1", "Alex.Muller.0", "Alex.Phil", "Lex"]The interviewer was very nice and understood how everyone is different. He left it to my discretion on whether to speak out loud about what i am thinking or just think and code (I feel this is how every interviewer should be). And frankly it just boosts your confidence if you are allowed to think and code, or code and think loud and are not pressurised to follow an approach particularly.
Anyways i contunued and kept pouring out whatever was in my mind as that is what i have practiced and developed after many tech interviews.
The question just took me aback at first because of the unfamiliarity.
The first approach that came to my mind was recurssion (or using a stack) [The only approach i still can think of].
I explained my approach properly and then he asked me to code it. (He wasn't very keen on listening to my approach)
I got confused on how to handle the recussion result (as in how and where to store, process it) and could not code the "Alex" test case.
After the interview, it took me 10 mins to code it up which speaks volumes about my pressure handling skills. It was humiliating as hell.
Takeaways:
Never think about solving all the problems you can here, just be focused on grasping concepts and always build upon a strong base.
Do not think about result of the interview (good / bad) inbetween the interview. I do this all the time and find myself in the middle of no where. (Any tips on how to get rid of this thought would be much appreciated).
Last but never the least : These takeaways may not work for everyone, just figure out who you are, what suits you the best and act accordingly.
def find_nulls(input):
output = []
def get_all_nulls(key, val):
ans = []
if isinstance(val, list):
for index, value in enumerate(val):
if not value:
ans = [key]
ans[-1] = ans[-1] + '.' + str(index)
break
elif isinstance(val, dict):
ans = find_nulls(val)
i = 0
while i < len(ans):
ans[i] = key + '.' + ans[i]
i += 1
elif not val:
ans = [key]
return ans
for key, val in input.items():
ans = get_all_nulls(key, val)
if ans:
output.extend(ans)
return outputI hope this helps.
Keep hustling. Signing off.