Find Each User's Earliest Seven-Day Activity Streak
Last updated: August 3, 2026
Quick Overview
The question asks the candidate to find each user's earliest seven-day activity streak from a dataset, requiring data manipulation skills using SQL or Python.
ByteDance
August 3, 202612
0
101 solved
The question asks the candidate to find each user's earliest seven-day activity streak from a dataset, requiring data manipulation skills using SQL or Python.
This question is typically asked during the technical screen round for data science roles at ByteDance to assess the candidate's ability to manipulate and analyze data effectively. The interviewer evaluates the candidate's proficiency in SQL or Python, understanding of time series data, and ability to implement logic to identify patterns in user activity.
What the Interviewer Expects
- Demonstrates a clear understanding of data manipulation techniques in SQL or Python.
- Describes the logic to identify a seven-day activity streak for each user.
- Provides an efficient solution that considers performance and scalability.
- Includes handling of edge cases, such as users with less than seven days of activity.
- Explains the steps taken in the solution clearly and concisely.
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you optimize your solution for larger datasets?
- Can you explain how you would handle missing data in this analysis?
- What assumptions are you making about the data in your solution?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Requirements
To solve the problem of finding each user's earliest seven-day activity streak, we need to define what constitutes an activity streak. An activity streak is a period where a user has logged activity f...
High-Level Design
The approach involves several steps: First, we will aggregate the activity data by user and date. Next, we will identify consecutive days of activity for each user. Finally, we will filter these resul...