← PayPal Interview Insights

PayPal·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

PayPal data scientist interview, technical phone screen focused on SQL. One meaty question about tracking navigation sequences, which honestly took me longer to work through than I expected.

Questions Asked (1)

Q1

Given a table of page visit events with user, page, and timestamp columns, write SQL to find users who visited page A and then page B (in that order) within the same calendar day, never visited page C that day, and completed the A then B sequence more than once.

Product Analytics & MetricsAlgorithms & Data Structures
Author's notes

The 'more than once' part is what got me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a self-join or window functions to identify sequences of page visits per user per day, then filter for users who have at least two A→B sequences and no C visits on the same day. Ensure the A visit timestamp is strictly before the B visit timestamp and both occur on the same calendar date.

Pro tip: Clarify assumptions about timestamp granularity and timezone handling upfront, and mention that using window functions like LAG/LEAD can efficiently detect sequences without expensive self-joins.

1. Understand the data and requirements

Identify the table schema (user_id, page, timestamp) and clarify that 'same calendar day' means the date part of the timestamp. Confirm that sequences must be strictly ordered (A before B) and that C must not appear at all that day.

2. Filter and order events per user per day

Use a window function to order events by timestamp within each user and calendar day, or filter the table to only include relevant pages (A, B, C) to reduce data volume.

3. Detect A→B sequences

For each user and day, find pairs of consecutive events where page A is immediately followed by page B. Count the number of such sequences per user per day.

4. Exclude days with page C visits

Identify user-days that contain any visit to page C and remove them from the result set, ensuring the condition 'never visited page C that day' is met.

5. Filter for multiple sequences and return users

Keep only user-days where the count of A→B sequences is greater than 1, then select distinct users who satisfy all conditions.

Key Points to Mention

  • Use of window functions (e.g., LAG, LEAD) to compare consecutive events efficiently.
  • Handling of timestamp ordering and ensuring A occurs before B.
  • Definition of 'same calendar day' and potential timezone considerations.
  • Filtering out days with any page C visit using NOT EXISTS or LEFT JOIN.
  • Counting sequences per user per day and applying HAVING COUNT > 1.
  • Performance considerations: indexing on (user_id, timestamp) and filtering early.

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