Detect Repeated Douyin Uploads Within K Positions by Content Hash
Last updated: November 29, 2026
Quick Overview
Given the sequence of perceptual content hashes for a creator's uploads in order, return True if the same hash appears twice with indices at most k apart.
ByteDance
November 29, 20260
0
0 solved
Given the sequence of perceptual content hashes for a creator's uploads in order, return True if the same hash appears twice with indices at most k apart.
A warm-up in the style of ByteDance's online assessment for backend roles on the Douyin upload team, where accidental double submissions from flaky mobile networks are common. The interviewer checks that you reach the single-pass hash map solution quickly and reason about the window boundary correctly.
What the Interviewer Expects
- Clarify whether the distance is inclusive (i - j <= k)
- Use a hash map of last seen index in one pass
- Explain why storing only the latest index is sufficient
- State O(n) time and O(n) space, or O(k) with a sliding set
- Handle k = 0 and empty input
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
- How would you bound memory to O(k) instead of O(n)?
- What if hashes are near-duplicates within a Hamming distance rather than exact matches?
- How would this run as a streaming check on the upload service?
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 is a list of hash strings in upload order and an integer k >= 0. Return True if there exist i < j with hashes[i] == hashes[j] and j - i <= k. An empty list or k = 0 returns False because two dis...
High-Level Design
Walk the list once while remembering the most recent index at which each hash appeared. When we see a hash again, compare the current index to its last index. Only the latest index matters: any earlie...