Reported September 2026
Amazonhash table

Most Frequent Consecutive Website Pattern

Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Amazon OA. Under 2s to a working solution.
Founder's read

Amazon reported this one in September 2026, and it looks scarier than it is. Strip the story and it's a grouping problem: bucket visits by user, sort each bucket, slide a window of three, and count each triple once per user. The hash-table and sliding-window combo is the whole question. If you've got an Amazon OA invite and 48 hours, this is a pattern worth locking in. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but you shouldn't need it once you see the shape.

The problem

You are given three equal-length arrays describing website visits. Entry i contains a username, an integer timestamp, and a website.
For each user, sort visits by timestamp; when timestamps are equal, keep their original input order. Every three adjacent visits in that per-user order form a consecutive website pattern. A user contributes at most once to the count of any distinct pattern, even if that pattern occurs several times for the user.
Return the three websites in the pattern seen by the greatest number of distinct users. If several patterns have the same count, return the lexicographically smallest three-element sequence. If no user has at least three visits, return an empty array.

Function
mostFrequentConsecutivePattern(usernames: String[], timestamps: int[], websites: String[]) → String[]

Examples
Example 1
usernames = ["amy","amy","amy","ben","ben","ben"]
timestamps = [1,2,3,1,2,3]
websites = ["home","cart","pay","home","cart","pay"]
return = ["home","cart","pay"]
Both users have the consecutive pattern [home, cart, pay], so it has two distinct-user supporters.
Example 2
usernames = ["a","a","a","b","b","b"]
timestamps = [3,1,2,1,2,3]
websites = ["z","a","z","a","z","z"]
return = ["a","z","z"]
User a produces [a, z, z], and user b produces the same pattern. Sorting is performed within each user rather than on the global input.
Example 3
usernames = ["a","a","b"]
timestamps = [1,2,1]
websites = ["x","y","z"]
return = []
No user has three visits, so no consecutive triple exists.

Constraints
0 <= usernames.length <= 5000.
usernames.length == timestamps.length == websites.length.
Usernames and websites contain 1 to 30 lowercase English letters.
0 <= timestamps[i] <= 10^9.
Input rows may be globally unordered; equal timestamps for one user retain input order.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Here's what it reduces to. Build a map from user to a list of (timestamp, website) pairs, keeping input index so ties stay in original order. A stable sort on timestamp handles that. For each user with three or more visits, slide a window of three and put each triple into a per-user set. Then add one to a global counter for every triple in that set. That set is the distinct-user rule. Finally pick the highest count, breaking ties with the lexicographically smallest triple. Join the three sites with a delimiter as the key, or use tuples. The common pitfall is counting a triple twice for one user, or sorting globally instead of per user. Another is a tie-break on the joined string, which can misorder if names have different lengths, so compare as arrays. With n up to 5000 and a per-user triple count of at most n, it's cheap. If you freeze on the live OA, StealthCoder is the hedge.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Most Frequent Consecutive Website Pattern cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as analyze user website visit pattern. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Amazon's OA.

Amazon reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Most Frequent Consecutive Website Pattern FAQ

What's the trick in the Amazon most frequent consecutive website pattern problem?+

Group by user, stable-sort by timestamp, slide a window of three, and dedupe triples per user with a set. Then count across users. The distinct-user rule is the part people miss. Everything else is a plain hash map and a sort.

How hard is this problem really?+

Medium at most. No fancy algorithm is needed. The difficulty is careful bookkeeping: stable ordering on equal timestamps, per-user dedupe, and the lexicographic tie-break. With 5000 rows, brute force per user is fine.

How do I handle equal timestamps for the same user?+

Keep the original input order. Use a stable sort on timestamp, or sort by the pair of timestamp and original index. Don't sort globally and then regroup, since that can scramble ties if your sort isn't stable.

How should I break ties between patterns with equal counts?+

Return the lexicographically smallest three-element sequence. Compare element by element as arrays or tuples, not as one concatenated string. Joining with a delimiter that sorts below lowercase letters also works, but tuple comparison is safer.

How do I prepare for this in 48 hours?+

Write it once from scratch: map of user to visits, stable sort, window of three, per-user set, global counter, tie-break. Test on the three examples, including the empty-result case where no user has three visits. That covers it.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Amazon.

OA at Amazon?
Invisible during screen share
Get it