A manager at LinkedIn reached out to me, for a role under AM&D (Autonomous Mobility & Delivery). Thanks to him for pulling me in, because I did not interview well myself.
This round was 60 minutes. The interviewer was positive and engaged, we went back and forth, and the interview experience was good.
Design & Architecture
This was scheduled for 15 minutes, but we ended up talking for almost half an hour, and the coding part was extended accordingly. Basically I introduced my biggest project, and the interviewer asked a lot of follow-up questions about the details, including design choices and trade-offs.
Coding
One LeetCode-style question, about ad clicks and impressions. The ad structure looks like this:
Campaign
/ \
AdGroup1 Ad1
/ \
Ad2 Ad3
The following functionality had to be implemented:
// Register an ad node. This can be a campaign, an ad group, or an ad.
void AddAdEntity(String nodeId, String parentId);
// Consume an ad event. EventType is an enum as Click or Impression.
void ConsumeEvent(String id, String date, EventType eventType);
// Find the k worst performing ads for a given date and given ID by ad stats like impressions, clicks, and CTR. You can sort by CTR.
// The ID can be a campaign, an ad group.
List<String> getWorstK(String nodeId, String date, int k);
My problem was that I kept being stuck on using a Trie (prefix tree), and only at the end did I realize that a normal TreeNode with a parent pointer, propagating the stats upward, solves it. Of course, you also need a map from nodeId to node for lookups, which can be built and maintained inside AddAdEntity.
For getting the worst K, I answered that I would use a PriorityQueue to sort by date, which I felt was not ideal either. A TreeMap could be used instead, so no sorting is needed.
Discussion
Loading comments…