The Repeat Visitor
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Problem
Given a list of purchase records (dicts with 'user' and 'date' in 'YYYY-MM-DD' format) and integer days, return users who made at least two purchases within a rolling window: there exist two of their purchase dates d1 <= d2 with (d2 - d1) days <= days. Return the list of user IDs sorted alphabetically.
Summary
Loyal customers come back sooner than expected.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.