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
Data Manipulation (SQL/Python)
Data Scientist
ByteDance
August 3, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Medium

12

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
Data Manipulation
SQL Queries
Python Data Analysis
Time Series Analysis
Edge Case Handling
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported

Related Questions