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
Coding & Algorithms
Software Engineer
ByteDance
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

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
hash map
sliding window
streaming dedup
index distance
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported