Find Top Hashtags
Problem Description
You are provided with two arrays, tweets and timestamps, both of length n:
tweets[i]represents the string content of the i-th tweet.timestamps[i]represents the integer publish time of the i-th tweet.
Additionally, you are given two integers: currentTime and timeWindow.
Your task is to identify and count the popularity of hashtags within a specific time interval. Only tweets whose timestamps[i] fall within the inclusive range [currentTime - timeWindow, currentTime] should be considered.
A hashtag is defined as any token within a tweet's content that begins with the # symbol. The popularity of a hashtag is determined by the total number of times it appears across all relevant tweets within the specified time window.
Deliverables
Return a list containing the top 3 most popular hashtags.
- If fewer than 3 unique hashtags are found within the time window, return all of them.
- The list should be sorted primarily by hashtag count in descending order.
- In the case of a tie in popularity count, hashtags should be sorted lexicographically in ascending order.
AI interview prep
Core dilemma
Efficiently processing a potentially large dataset of tweets to extract, count, and rank hashtags within a dynamic time window, balancing computational complexity with memory usage.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Find Top Hashtags
Problem Description
You are provided with two arrays, tweets and timestamps, both of length n:
tweets[i]represents the string content of the i-th tweet.timestamps[i]represents the integer publish time of the i-th tweet.
Additionally, you are given two integers: currentTime and timeWindow.
Your task is to identify and count the popularity of hashtags within a specific time interval. Only tweets whose timestamps[i] fall within the inclusive range [currentTime - timeWindow, currentTime] should be considered.
A hashtag is defined as any token within a tweet's content that begins with the # symbol. The popularity of a hashtag is determined by the total number of times it appears across all relevant tweets within the specified time window.
Deliverables
Return a list containing the top 3 most popular hashtags.
- If fewer than 3 unique hashtags are found within the time window, return all of them.
- The list should be sorted primarily by hashtag count in descending order.
- In the case of a tie in popularity count, hashtags should be sorted lexicographically in ascending order.