Find Click Sequences of Length L Repeated Within a Session Log
Last updated: November 29, 2026
Quick Overview
Given a session's click log as a string of single-character event codes and a length L, return every length-L sequence of events that occurs more than once in the log.
Meta
November 29, 20260
0
0 solved
Given a session's click log as a string of single-character event codes and a length L, return every length-L sequence of events that occurs more than once in the log.
A sliding window plus hashing problem drawn from Meta clickstream analysis, where repeated navigation loops can signal confusing UI or bots. The interviewer checks the basic set approach and then probes memory with rolling hashes.
What the Interviewer Expects
- Slides a window of length L and records substrings in a seen set
- Adds to a result set only on the second occurrence, avoiding duplicates
- Discusses the O(n * L) cost of slicing and hashing each substring
- Offers a rolling hash (Rabin-Karp) to make each step O(1)
- Handles L larger than the log
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Make each step O(1) with a rolling hash. How do you handle collisions?
- Return the count of each repeated sequence.
- Find the longest sequence that repeats at least twice.
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: log, a string over a small alphabet of event codes, and L >= 1. Output: the sorted list of distinct length-L substrings that appear at least twice (occurrences may overlap)....
High-Level Design
Walk every start index from 0 to n - L. For each window substring, if it is already in seen, add it to repeated; otherwise add it to seen. Using a set for repeated stops a third occurrence fro...