Count Repeat Customers Across Dates
Problem statement
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) → intExamples
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 = 1alice 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 = 1The 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 = 1Two 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
visitscontains exactly two non-empty strings: a customer ID and a timestamp. - Every customer ID contains at most
64English letters, digits, hyphens, or underscores. - Every timestamp,
windowStart, andwindowEndis a valid UTC value in the fixed formatYYYY-MM-DDTHH:MM. windowStart <= windowEnd.- The visits may be in any order.