I interviewed for a Senior SDE role at Shopify. The interviewer was very easy to talk to and things went smoothly. The problem was to write a local tiny URL shortener, similar to a LeetCode-style problem.
We discussed the following points together:
- Input validation: checking whether the input URL is well-formed.
- Encoding: use an MD5 hash, and we discussed how to handle hash collisions.
- How to store the mapping between the shortened URL and the source URL: we decided to store the mapping in a hashmap (both Redis and a small database were ruled out — the interviewer felt that was overengineering), and serialize it into a JSON file when it's not in use. The next time it's needed, load that JSON file first.
- Estimating how much memory is needed based on the number of URLs: it came out to roughly 1TB. I said a high-end server would have enough memory, and if not, we could shard. The interviewer said there was no need to overthink it.
- Testing: 1) line and branch coverage should be above 90%, 2) invalid input, 3) hash collisions, 4) duplicate requests for the same URL, 5) extremely long URLs.
After the discussion, I put everything together into a prompt in markdown and fed it to an AI. The code came together quickly. The interviewer and I did a quick review together and it looked fine. I checked coverage with pytest-cov and it was above 90%. I also manually tested a few cases and they were all correct. The interviewer seemed satisfied and had me push the code into the Q&A part.
A week after the interview I got the notification that I was rejected. Since the whole approach was improvised on the spot, it probably just didn't match what the interviewer had in mind. Anyway, moving on.
Discussion
Loading comments…