Compute a Learner's Current Streak With Streak Freezes
Last updated: November 29, 2026
Quick Overview
Given the set of day numbers on which a learner completed at least one lesson, today's day number, and how many streak freezes they have equipped, return the length of their current streak. A freeze silently covers one missed day but does not add to the streak.
Duolingo
November 29, 20260
0
0 solved
Given the set of day numbers on which a learner completed at least one lesson, today's day number, and how many streak freezes they have equipped, return the length of their current streak. A freeze silently covers one missed day but does not add to the streak.
Streaks are one of Duolingo's core retention mechanics, so a phone screen may open with a small problem modeled on them. The interviewer is checking that you pin down the rules (is today already lost? does a freeze count as a streak day?) before coding, and that you handle empty and boundary inputs cleanly.
What the Interviewer Expects
- Asks whether an inactive today breaks the streak or is still pending
- Clarifies that frozen days protect but do not extend the streak
- Uses a set for O(1) membership instead of scanning a list per day
- Stops walking back at the earliest active day so freezes are not wasted on pre-history
- Tests empty input, all freezes used, and a gap larger than the freeze count
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return which days were consumed by freezes so the calendar UI can show them?
- How do time zones change the definition of a day if a learner travels?
- If freezes auto-replenish weekly, how would the walk change?
- How would you compute the longest streak ever, not just the current one?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: active_days (ints, possibly unsorted), today, freezes. Output: number of active days in the unbroken chain ending today or yesterday. Rules I would confirm: if the learner has not practic...
High-Level Design
Put the days in a set. Start at today if active, otherwise yesterday, and walk backwards one day at a time. Active days increment the count, missed days spend a freeze, and the walk stops when a miss ...