Longest Run of Consecutive Days With Growing Threads Signups
Last updated: November 29, 2026
Quick Overview
From a daily table of new Threads signups, find the longest streak of consecutive days on which signups were higher than the previous day, returning its first day, last day and length.
Meta
November 29, 20260
0
0 solved
From a daily table of new Threads signups, find the longest streak of consecutive days on which signups were higher than the previous day, returning its first day, last day and length.
A gaps-and-islands warm-up in Meta data science screens, framed around a growth review for Threads. The interviewer checks LAG for the comparison and a running sum of breaks to label streaks, plus clear handling of ties and the first day.
What the Interviewer Expects
- Compare each day to the previous with LAG
- Mark non-growth days as streak breaks
- Label streaks with a running sum of breaks
- Aggregate each streak and pick the longest
- Decide how equal days and the first day are treated
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 allow one flat day inside a streak?
- How would you find the longest streak per country?
- Why is this a weak growth signal on its own?
- How would you use a 7-day average instead of raw days?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
threads_signups(ds, signups), one row per day, no gaps. A growth day has signups > previous day; an equal day breaks the streak. The first day has no previous value, so it is not a growth day. The...
Approach
LAG gives the previous value; a growth flag is 1 when today is higher. A running SUM of non-growth flags assigns the same label to every growth day following a given break, so each label is one streak...