Problem · Greedy
Optimize TikTok Reels Viewing
Learn this problemProblem statement
A content creator wants to complete exactly m total viewings from a playlist of n TikTok reels in the least possible time.
- The first-time viewings must follow playlist order. You may stop after unlocking any prefix of the reels.
- The first viewing of reel
itakesinitialWatch[i] + repeatWatch[i]minutes. - After a reel has been watched once, each additional viewing of it takes
repeatWatch[i]minutes. - Rewatches may use any already unlocked reel and may occur in any order.
Return the minimum total time required to complete exactly m viewings.
Function
optimizeTikTokWatchTime(n: int, initialWatch: int[], repeatWatch: int[], m: int) → longExamples
Example 1
n = 4initialWatch = [1, 5, 9, 11]repeatWatch = [2, 7, 10, 11]m = 4return = 9Unlock only the first reel for 1 + 2 = 3 minutes, then rewatch it three times for 3 * 2 = 6 minutes. The total is 3 + 6 = 9.
Constraints
1 ≤ n ≤ 10^51 ≤ m ≤ 10^9initialWatch.length = repeatWatch.length = n1 ≤ initialWatch[i], repeatWatch[i] ≤ 10^9
More Tiktok problems
- Count Access Code PairsOA · Seen Jul 2026
- Count Key ChangesOA · Seen Jul 2026
- Travel Distance on ScootersOA · Seen Jul 2026
- Count Skipped Numbers After SubtractionsOA · Seen Jul 2026
- Obstacle Placement QueriesOA · Seen Jul 2026
- Repeated Grouped Digit SumOA · Seen Jul 2026
- Count Cyclic Digit PairsOA · Seen Jun 2026
- Event ID Check Completion TimesOA · Seen Jun 2026