FastPrepMost Common Three-Website Sequences
Problems/Most Common Three-Website Sequences

Most Common Three-Website Sequences

Amazon logoAmazon● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon new grad phone screen. The report describes records with a timestamp, a customer, and a webpage. It asks for the three most visited sequences of three webpages, using hash maps and a heap. It does not give rules for ties or for a customer who repeats. We made those rules fixed. Our version is about 88% the same as the reported question.

The parallel arrays timestamps, customers, and webpages describe webpage visits. Record i means that customers[i] visited webpages[i] at timestamps[i].

A three-website sequence chooses any three visits by the same customer in strictly increasing timestamp order; the visits do not need to be consecutive. A sequence's score is the number of distinct customers who produced it. Repeating the same sequence multiple times for one customer contributes only one point.

Return up to the three highest-ranked sequences. Rank by descending score, then lexicographically by the three website names. Serialize each result as "first>second>third".

Function

topWebsiteSequences(timestamps: int[], customers: String[], webpages: String[]) → String[]

Examples

Example 1

timestamps = [1,2,3,4,5,6]customers = ["u1","u1","u1","u2","u2","u2"]webpages = ["home","search","cart","home","search","cart"]return = ["home>search>cart"]

Both customers produce home, search, cart, so it has score two and is the only sequence.

Example 2

timestamps = [1,2,3,4,5,6,7]customers = ["u1","u1","u1","u1","u2","u2","u2"]webpages = ["a","b","a","c","a","b","c"]return = ["a>b>c","a>a>c","a>b>a"]

a>b>c has score two. The score-one ties are resolved lexicographically.

Example 3

timestamps = [8,2]customers = ["u1","u2"]webpages = ["home","cart"]return = []

No customer has three visits, so no sequence exists.

Constraints

  • 1 <= timestamps.length = customers.length = webpages.length <= 60.
  • All timestamps are distinct integers from 1 through 10^9.
  • Customer IDs and webpage names are nonempty lowercase alphanumeric strings of length at most 20.
  • Webpage names do not contain >.

More Amazon Phone Screen questions

  • Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 3SumPHONE SCREEN · Seen Nov 2026
  • Circular Primes Below a LimitPHONE SCREEN · Seen Nov 2026
  • Cheapest Flights Within K StopsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Two SumOA · PHONE SCREEN · Seen Nov 2026
  • Count the 1 Bits in a 32-Bit ValuePHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Longest Consecutive SequenceJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
  • Top K Frequent Elements with a Recency TiebreakSwiggy · PHONE SCREEN
  • Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
  • Group AnagramsWorkday · PHONE SCREEN
  • Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
  • Build a Task and Subtask HierarchyStripe · PHONE SCREENStripe interview questions
  • Find All Points Within a RadiusGoogle · PHONE SCREENGoogle interview questions
  • Find Valid SET Card TriplesSnowflake · OA · PHONE SCREENSnowflake interview questions
  • Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREENPerplexity AI interview questions

Amazon interview experiences

  • Amazon SWE OA with AI Coding: 1 Experience
  • Amazon SWE Intern Phone Screen Interview Experience: 1 Experience
  • Amazon New Grad SDE I OA and Virtual Onsite: 1 Experience
  • Amazon BIE Intern SQL and Interview Questions: 17 Experiences
  • Amazon Experienced SWE AI-Assisted Debugging OA: 1 Experience
  • Amazon SDE II (L5) Interview Questions: 5 Experiences
See Amazon hiring insights
Saved
class Solution {
    public String[] topWebsiteSequences(int[] timestamps, String[] customers, String[] webpages) {
      // write your code here
    }
}
Checking account…