PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Bytedance

Maximize watch time under adjacency constraint

Last updated: Mar 29, 2026

Quick Overview

This Coding & Algorithms question for a Data Engineer role evaluates dynamic programming and sequence-optimization skills by requiring selection of a subsequence under a pairwise adjacency constraint on video durations, at a moderate-to-advanced algorithmic abstraction level.

  • hard
  • Bytedance
  • Coding & Algorithms
  • Data Engineer

Maximize watch time under adjacency constraint

Company: Bytedance

Role: Data Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given a sequence of videos in a feed. - Input: - An integer array `duration[1..n]`, where `duration[i]` is the length of video `i` in seconds. - An integer `A` (the user’s attention limit). - Task: - Select a subset of videos **in the original order** (i.e., choose a subsequence). - Let the selected videos be `i1 < i2 < ... < ik`. The constraint is: - For every adjacent pair in the selected subsequence, `duration[ij] + duration[ij+1] <= A`. - Maximize the total watch time: `sum(duration[ij])`. - Output: - Return the maximum achievable total watch time. Follow-up: - Suppose the user is allowed to rewatch the same video multiple times, and the session consists of exactly `m` selections (so repetitions are allowed, but the number of watched items is capped). How would you modify your approach to compute the maximum total watch time under the same adjacency constraint?

Quick Answer: This Coding & Algorithms question for a Data Engineer role evaluates dynamic programming and sequence-optimization skills by requiring selection of a subsequence under a pairwise adjacency constraint on video durations, at a moderate-to-advanced algorithmic abstraction level.

Related Interview Questions

  • Reverse Nodes in K-Sized Groups - Bytedance
  • Solve Bracket Matching and Tree Width - Bytedance (hard)
  • Reverse Linked List Groups - Bytedance (medium)
  • Solve Stack and String Shift Problems - Bytedance (medium)
  • Find LCA With Parent Pointers - Bytedance (medium)
Bytedance logo
Bytedance
Jan 2, 2026, 12:00 AM
Data Engineer
Technical Screen
Coding & Algorithms
3
0

You are given a sequence of videos in a feed.

  • Input:
    • An integer array duration[1..n] , where duration[i] is the length of video i in seconds.
    • An integer A (the user’s attention limit).
  • Task:
    • Select a subset of videos in the original order (i.e., choose a subsequence).
    • Let the selected videos be i1 < i2 < ... < ik . The constraint is:
      • For every adjacent pair in the selected subsequence, duration[ij] + duration[ij+1] <= A .
    • Maximize the total watch time: sum(duration[ij]) .
  • Output:
    • Return the maximum achievable total watch time.

Follow-up:

  • Suppose the user is allowed to rewatch the same video multiple times, and the session consists of exactly m selections (so repetitions are allowed, but the number of watched items is capped). How would you modify your approach to compute the maximum total watch time under the same adjacency constraint?

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Bytedance•More Data Engineer•Bytedance Data Engineer•Bytedance Coding & Algorithms•Data Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.