Description
Solutions
Submission
Maximum Shown Segments
🔥 FULLTIME

The TikTok video content analyzer, which is always eager to get the highest views, faced a unique task that required pure coding. The task provided the students with a series of video clips and posed a question based on the content in these clips. Each question involved two missions: to determine the maximum number of views and the students must find an algorithm that determines the maximum number of video views while still showing the most successful creators.

The student's task is to calculate, for each question, the maximum number of video segments that can create the highest engagement. In no valid case will be 0, as possible, the answer should be the maximum number of views that can be achieved by showing clips from the most successful creators.

Function Description

Complete the function maxShownSegments in the editor below.

maxShownSegments has the following parameters:

  • int arr[n]: an array representing the lengths of video clips
  • int k: a threshold to determine how many partitions of video segments are allowed


Example 1:

Input:  arr = [5, 1, 2, 3, 1], k = 2
Output: 3
Explanation:

Example 2:

Input:  arr = [1, 3, 5, 3, 1], k = 2
Output: 3

Example 3:

Input:  arr = [6, 4, 5, 1, 7], k = 5
Output: 0
Explanation:
Constraints:
    TO-DO
Thumbnail 0
Testcase

Result
Case 1

input:

output: