Back to problems

Frequent Page Visit Pattern

Algorithm · Amazon · Medium

You are given a chronological list of pages visited by users. You may assume that both the page list and the visit data fit in memory. Implement mostFrequentTriplet(pages), which takes the page list and returns the most frequent consecutive three-page sequence. If multiple sequences are tied for highest frequency, return any one of them. Example Explanation: The consecutive triplet H,I,J appears three times, which is more frequent than any other three-page sequence.

Checking your access…