← Stripe Interview Insights

Stripe·Software Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Stripe Android Engineer interview with a billing/interval-union coding problem. Pretty algorithmic for a mobile role, which surprised me a bit, but the problem itself was well-defined once I slowed down and read it carefully.

Questions Asked (1)

Q1

Given a stream of chat session events with timestamps and user IDs, compute the total billable seconds per user. Sessions can overlap, so you need to count the union of intervals rather than summing durations naively. Malformed sessions where the end is before the start should be discarded.

Algorithms & Data StructuresPricing & Monetization
Author's notes

I started by just summing end minus start for each session and almost submitted that before catching the overlap issue.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the input format and edge cases (e.g., malformed sessions, overlapping intervals, multiple sessions per user). Then, for each user, collect valid intervals, sort them by start time, and merge overlapping intervals to compute the union length. Finally, sum the merged durations per user and return the result.

Pro tip: Mention that you would handle malformed sessions early by filtering them out, and discuss how to scale the solution for large streams (e.g., using a heap or streaming merge). Also, consider if sessions can be open-ended (no end timestamp) and how to handle that.

1. Clarify requirements and edge cases

Ask about input format (e.g., list of events, each with start/end timestamps and user ID), whether sessions can be open-ended, and how to handle malformed sessions. Confirm that billable seconds are the union of intervals per user.

2. Filter and group sessions by user

Discard malformed sessions where end < start. Group valid sessions by user ID, storing intervals as (start, end) pairs.

3. Merge overlapping intervals per user

For each user, sort intervals by start time. Iterate through sorted intervals, merging overlapping ones by updating the end time to the maximum of current end and next end.

4. Compute total billable seconds

Sum the lengths of the merged intervals for each user. Return a mapping of user ID to total billable seconds.

5. Analyze complexity and scalability

Discuss time complexity: O(N log N) per user due to sorting, or O(N log N) overall if sorting all intervals globally. Mention potential optimizations for streaming data, such as using a balanced tree or heap.

Key Points to Mention

  • Handling malformed sessions by discarding them (end < start).
  • Grouping intervals by user ID before merging.
  • Sorting intervals by start time and merging overlapping intervals.
  • Computing union length by summing merged interval durations.
  • Time complexity: O(N log N) due to sorting; space complexity O(N).
  • Edge cases: zero-length sessions, sessions with same start/end, large number of users, streaming input.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.