FastPrepCount Repeat Customers Across Dates
Problems/Count Repeat Customers Across Dates

Count Repeat Customers Across Dates

Amazon logoAmazon● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon full-time phone screen. The report says a repeat customer is one who comes in on more than one date, and asks about one shared time window and a very large log. It does not give the record format, the timestamp format, the window edges, what to do with duplicate rows, or the number limits. Our version is about 88% the same as the reported question.

You are given an array visits. Each row contains exactly two strings: [customerId, timestamp]. Every timestamp is a valid UTC value in the fixed format YYYY-MM-DDTHH:MM.

Only visits whose timestamps are between windowStart and windowEnd, inclusive, belong to the reporting window.

A customer is a repeat customer when that customer has at least one visit on each of two different calendar dates inside the reporting window. Multiple visits by the same customer on the same date count once for this rule.

Return the number of repeat customers.

Function

countRepeatCustomers(visits: String[][], windowStart: String, windowEnd: String) → int

Examples

Example 1

visits = [["alice","2026-08-18T09:00"],["bob","2026-08-18T09:15"],["alice","2026-08-19T10:00"],["bob","2026-08-18T17:00"],["cara","2026-08-20T12:00"]]windowStart = "2026-08-18T00:00"windowEnd = "2026-08-19T23:59"return = 1

alice visits on August 18 and August 19 inside the window. Both of bob's visits are on August 18, and cara's visit is outside the window.

Example 2

visits = [["a","2026-08-01T00:00"],["a","2026-08-02T23:59"],["b","2026-08-02T23:59"],["b","2026-08-03T00:00"],["c","2026-08-02T12:00"]]windowStart = "2026-08-01T00:00"windowEnd = "2026-08-02T23:59"return = 1

The window includes both boundary timestamps. Customer a appears on two dates. Customer b's August 3 visit is outside the window, and c appears on one date.

Example 3

visits = [["u1","2026-09-01T08:00"],["u1","2026-09-01T09:00"],["u2","2026-09-01T10:00"],["u2","2026-09-02T10:00"]]windowStart = "2026-09-01T00:00"windowEnd = "2026-09-02T23:59"return = 1

Two visits by u1 on the same date do not make that customer repeat. Customer u2 visits on two different dates.

Constraints

  • 0 <= visits.length <= 200000.
  • Every row in visits contains exactly two non-empty strings: a customer ID and a timestamp.
  • Every customer ID contains at most 64 English letters, digits, hyphens, or underscores.
  • Every timestamp, windowStart, and windowEnd is a valid UTC value in the fixed format YYYY-MM-DDTHH:MM.
  • windowStart <= windowEnd.
  • The visits may be in any order.

More Amazon Phone Screen questions

  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Spread Through a GridPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Consistent-Hash Packet RouterPHONE SCREEN · Seen Nov 2026
  • Count Connected ComponentsPHONE SCREEN · Seen Nov 2026
  • Second Largest Distinct ElementPHONE SCREEN · Seen Nov 2026
  • Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
  • Deep Merge with a Conflict ResolverAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEWDuolingo interview questions
  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Group AnagramsWorkday · PHONE SCREEN
  • Video Cache Hit Rates from a CSV LogTubi · PHONE SCREEN
  • Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions

Interview reports that mention this question

  • Amazon Experienced Hire OA and Interviews: 21 Experiences

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int countRepeatCustomers(String[][] visits, String windowStart, String windowEnd) {
        // Write your code here.
    }
}
Checking account…