InterviewDB Question

Purchase Pattern Detection - Coding Interview

Question Details

Problem Given a list of purchase events for a single user, each as (item_id, timestamp), determine the most frequent consecutive purchase pattern of length k. A pattern is a sequence of exactly k distinct items bought in consecutive transactions (no gaps). Return the pattern as a list of item IDs in the order they were purchased. If there is a tie, return the lexicographically smallest sequence. Example: Constraints: 1 <= k <= len(purchases), timestamps are strictly increasing. Follow-ups How do…

Full Details

🔒

Unlock all Affirm questions

Full insider details, leaked discussions, and candidate experiences.

Get full access — $100 a year, unlimited access

About This Question

This is a reported interview question from a affirm interview during the phone round.

It covers the following topics: Coding, Onsite, Phone .