FastPrepCrossed User Pairs on One Date
Problems/Crossed User Pairs on One Date

Crossed User Pairs on One Date

Rippling logoRippling● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: An SDE-2 candidate's post from June 8, 2024, about a Bangalore loop that ended in an offer, lists two coding questions in its third round. The first one counts out-of-order pairs within one day of an activity log that is only ever appended to: two entries where the larger user id comes with the earlier time.

The post gives no input format, limits, examples or tie rules, and it speaks of a number of users without saying how a user who appears many times is handled. Here, the log is three parallel lists in written order, so dates never go down and times within a date never go down. A time is whole seconds after midnight. The answer counts pairs of entries, not users, so the same two users can add several pairs. Two entries with the same time or the same user id never pair. A date with no entries gives 0. At most 3,000 entries are given in memory, so reading a file too big for memory is not graded. The limits and examples are our own.

Our version is about 60% the same as the reported question.

A service writes one log entry each time a user does something. Entry i has a date dates[i], a time times[i] (whole seconds after midnight on that date) and the user's id userIds[i]. New entries are only ever added to the end of the log, so the dates never go down, and within one date the times never go down. Several entries can share a time, and one user can appear many times.

Two entries on the same date form a crossed pair when one of them has an earlier time but a larger user id than the other. That is, entries i and j form a crossed pair when times[i] < times[j] and userIds[i] > userIds[j]. Two entries with the same time, or with the same user id, never form a crossed pair.

Return the number of crossed pairs among the entries whose date is date. Each pair of entries counts once. If no entry has that date, return 0.

Function

countCrossedPairs(dates: String[], times: int[], userIds: int[], date: String) → int

Examples

Example 1

dates = ["2024-06-02","2024-06-03","2024-06-03","2024-06-03","2024-06-03","2024-06-04"]times = [86000,10,20,20,35,5]userIds = [5,9,4,7,2,1]date = "2024-06-03"return = 5

Only the four entries dated 2024-06-03 count. User 9 at time 10 crosses users 4 and 7 at time 20 and user 2 at time 35, which is 3 pairs. Users 4 and 7 at time 20 each cross user 2 at time 35, which is 2 more. Users 4 and 7 share time 20, so they do not form a pair. The answer is 5.

Example 2

dates = ["2024-06-01","2024-06-01"]times = [100,200]userIds = [8,3]date = "2024-06-05"return = 0

No entry has the date 2024-06-05, so the answer is 0. The crossed pair on 2024-06-01 does not count.

Example 3

dates = ["2024-01-15","2024-01-15","2024-01-15","2024-01-15","2024-01-15"]times = [0,0,60,60,120]userIds = [7,3,7,5,3]date = "2024-01-15"return = 4

User 7 at time 0 crosses user 5 at time 60 and user 3 at time 120 (2 pairs), but not user 7 at time 60, because the ids are equal. User 3 at time 0 has no later entry with a smaller id. User 7 and user 5 at time 60 each cross user 3 at time 120 (2 pairs). The two entries at time 0 share a time, so they do not pair. The answer is 4.

Constraints

  • 1 <= dates.length <= 3000, and times and userIds have the same length as dates
  • Every dates[i], and date, is a real calendar date written as YYYY-MM-DD.
  • 0 <= times[i] <= 86399
  • 1 <= userIds[i] <= 10^9
  • The entries are in the order they were written: the dates never go down, and among entries with the same date, the times never go down.

More Rippling Onsite Interview questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Delivery Cost TrackerPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Maximum Currency Conversion Along a Simple PathPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Top K Frequent WordsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Future-Effective Employee SalaryONSITE INTERVIEW · Seen Aug 2026
  • Filter and Sort Scheduled TasksONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Longest Consecutive Login StreakAmazon · ONSITE INTERVIEW
  • Group AnagramsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Top K Frequent ElementsCapgemini · ONSITE INTERVIEWCapgemini interview questions
  • Find Duplicate Element PairsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Mutual-Friend RecommendationsMeta · ONSITE INTERVIEWMeta interview questions
  • Top-K URLs Overall and in the Last 24 HoursOracle · PHONE SCREEN · ONSITE INTERVIEWOracle interview questions
  • Read a File from Distributed ChunksHudson River Trading · ONSITE INTERVIEWHudson River Trading interview questions
  • Top K Frequent ElementsInfosys · ONSITE INTERVIEWInfosys interview questions
  • Nickname-Constrained GroupingZoox · ONSITE INTERVIEW

Interview reports that mention this question

  • Rippling SDE-1 and SDE-2 Onsites: 14 Experiences (Part 9 of 12)
  • Rippling Full-Time SWE Interviews: 224 Experiences (Part 1 of 12)

Rippling interview experiences

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)
  • Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
  • Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
  • Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public int countCrossedPairs(String[] dates, int[] times, int[] userIds, String date) {
        // Write your code here.
    }
}
Checking account…