Optimize TikTok Reels Viewing
A content creator is taking on a challenge to get really good at TikTok. Instead of regular activities, they decide to focus on a playlist of TikTok reels.
To master TikTok, they set a goal to watch the reels a total of m times. But they want to do this in the least amount of time possible. Here's how it works:
initialWatch[i] + repeatWatch[i] for the i-th reel.repeatWatch[i] minutes per reel.m.Optimization Goal: The creator aims to minimize the total time spent watching the reels while fulfilling the above constraints. This involves strategically planning which reels to repeat and how often, given the reduced time for repeat viewings.
Complete the function optimizeTikTokWatchTime in the editor below.
optimizeTikTokWatchTime has the following parameter(s):
int n: an integer denoting the total number of reel viewings the creator aims to complete.int initialWatch[n]: an integer array denoting the minutes to watch the i-th reel for the first time.int repeatWatch[n]: an integer array denoting the minutes to rewatch the i-th reel.int m: the target count of reel viewings.
Returns
int: an integer denoting the minimum total minutes required for the creator to reach their target (m) count of reel viewings.
1Example 1
Constraints
Limits and guarantees your solution can rely on.
1 <= n <= 1051 <= m <= 1091 <= initialWatch[i], repeatWatch[i] <= 109