Uber Mock Interview Retrospective
Like mentioned in the previous post, I did a public mock coding interview. A reminder what that was:
- The goal was to explain how some bits of Uber’s tech recruiting works.
- The meetup page had 602 attendees as of writing. We expected quite a few participants in the event.
The mock interview consisted of:
- Introduction by Uber’s EMEA recruiter Courtney Cox.
- Myself doing a coding challenge with a 50 minute cap:
- I did not know the exercise upfront.
- Although my job did not depend on it, the ticking timer and people looking at my work (~260) made it quite stressful.
- I did not complete the exercise. According to my interviewee, I failed the “phone screen”. The good part is that I still get to keep my job. :)
- Half-hour QA session.
TLDR: Highlights
- Lots of fun for everyone: myself, the interviewer and the spectators.
- Folks seemed to be engaged: the chat room was active throughout, and we had more questions than time to answer them.
- Even though I have been coding Zig for the last few months, I felt like I had a strong enough grip on it; the algorithm was the one that tripped me.
TLDR: Lowlights
Most importantly, I did not complete the exercise. Worse, I did not even come up with the correct algorithm, therefore the interview was an obvious failure. I can re-apply in 6 months though!
Biggest mistake? I did the same mistake that interviewees do all the time: start coding without knowing the full algorithm. This is a recipe for failure. It is always, always better to spend 10-15 minutes with hands off the keyboard and come up with the solution, and only then start coding.
On the same day I figured out the solution and implemented it next morning. You can find it below. If you want to show this off in your favorite programming language, read below in the challenge section.
The Exercise and Solution
I have been coding in Zig since last February (so ~5 months now). Loris
Cro keeps telling the me and The Internet that Zig is not suitable for
coding challenges. Well, after a couple of months of working with him, I can
finally say he is wrong! Even though my colleagues tell me Zig was tripping me
(e.g. memory leaks in the unit tests, for which I had to add defer hash_map.deinit()
), I think this was due to lack of experience in a particular
“coding challenge setting”. Next time I will construct an arena and be
done with memory management.
Exercise was taken from Cracking the coding interview:
// Each year, the government releases a list of the 10000 most common baby
// names and their frequencies (the number of babies with that name). The only
// problem with this is that some names have multiple spellings. For example,
// "John" and "Jon" are essentially the same name but would be listed
// separately in the list. Given two lists, one of names/frequencies and the
// other of pairs of equivalent names, write an algorithm to print a new list
// of the true frequency of each name. Note that if John and Jon are synonyms,
// and Jon and Johnny are synonyms, then John and Johnny are synonyms. (It is
// both transitive and symmetric.) In the final list, any name can be used as
// the "real" name.
//
// Example:
// Names: John (15), Jon (12), Chris (13), Kris (4), Christopher (19)
// Synonyms: (Jon, John), (John, Johnny), (Chris, Kris), (Chris, Christopher)
// Output: John (27), Kris (36)
My solution
Timeline:
- 50 minutes during the interview. I almost did not use any of it except for small parsing bits and the unit test.
- 30 minutes after cycling home right after the meetup: thinking about the problem. At this point I realized this problem reduces to finding disconnected graphs.
- 2 hours 15 minutes: coding. The result of that is below.
|
|
Jakub Konka was watching the interview too! His comment to the solution above is:
- Your solution looks good to me and I think I’d be oscillating roughly around the same solution too.
- You’ve used arena in an interesting way to init string sets: I think I’d use an unmanaged version and initialize on first use.
- But it’s fine either way.
Optional: challenge for you
Inclined to show off your solution in Zig or your favorite programming language? Post it to the comment in meetup page (preferably use a public pastebin to keep the comment size reasonable), and I will paste my favorite ones here with your name. Please include the time it took you to code it. The main criteria is, of course, lines of code. :)
Thanks
Many thanks to Brigita Žemgulytė, Courtney Cox, Ignas Kaziukėnas and Mantas Mikšys for making this happen. I would do it again.