Round 1
Questions:
Question 1: Ad Event ingestion
You are given a class called AdEvent
, which contains attributes of uuid
(id for ad), timestamp
(represented in YYYY-MM-DD format), but you can make it some integer value for easier testing, and event_type
(either impression or click).
Write the following functions:
consume_ad_event(ad_event)
: Take in an ad event and consume it.get_historical_metrics(id)
: Given an ad id, return an output that looks like the following (note that the 1, 2, 3 in the test example are timestamp)
1: impressions - 5, clicks - 5 2: impressions - 10, clicks - 2 3: impressions - 15, clicks - 20, ....
has_low_performance(id, timestamp)
: Given an ad id along with a timestamp, identify if there were at least X impressions without any click in the last Y days. This signifies that an ad is receiving views, but no conversion! X and Y are hardcoded constants.
Follow Ups
- Suppose we store ad log events for 10 million days for each ad. What would the size of the data be? How would you handle the data volume/cost concern?
- Suppose we have a big company that makes advertisement in US, CA, JP, etc. How would you structure the backend database to support querying the performance metric by each country?
Question 2: Evaluator
You are given the following input:
equations
: an array with entry of format [ai, bi]. ai, bi are variables.values
: an array where values[i] = ai / bi.queries
: a list of lists represented in similar way toequations
.
For each query, compute the result. If unable to, return -1. Return a list of the results of the queries.
Note that this question is apparently this problem on leetcode: https://leetcode.com/problems/evaluate-division/description/
Follow Ups
- What if you had 10 million queries to this service? What design choices would you make to speed up the search?
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.