TikTok engineer position, first round (technical screen).
A variant of the classic LRU Cache problem (LeetCode 146).
First the interviewer introduced themselves, then asked me to introduce myself.
Then the interviewer asked: why are you looking to switch jobs, and why TikTok.
Then it was on to coding — the classic LRU Cache problem, but with an extra requirement: support for TTL. Specifically, TTL gets passed in as an extra parameter when the function is called, and you need to additionally handle the case where the TTL has expired.
I roughly walked through my approach: use a doubly linked list, with the difference being you need to add handling for TTL expiration — if something has expired, delete it, so it's treated as if that value doesn't exist, and then proceed with the operation.
Then I started writing the code. The problem itself was already hard difficulty, and on top of that I had to handle TTL, so the amount of code ended up being pretty large. I didn't finish 100% within the time limit — I wrote out the main code and logic, and used pseudocode for a few of the helper/sub-functions.
At the end I analyzed the time complexity, noting that using a doubly linked list gets you O(1).
Finally I asked the interviewer about the team, and that was it — interview over. One hour total.
Not long after, I got notified that I passed, even though the code part wasn't perfect.
Discussion
Loading comments…