FastPrepFastPrep
Problem Brief

TikTok Video Processing

INTERNOA
See Tiktok online assessment and hiring insights

TikTok is optimizing its video processing system. There are n video analyzers that can process videos based on their individual processing power. Each analyzer, represented by processingPower[i], has a unique capability in terms of how many videos it can handle at a time.

However, not all video analyzers can be used simultaneously for video processing. If an analyzer with processing power processingPower[i] is selected, then any analyzer with a processing power of (processingPower[i] - 1) and (processingPower[i] + 1) cannot be used due to interference in video content processing. Each analyzer can only be used once.

Given integers representing the video analyzers' processing power, determine the maximum achievable total processing power by selecting the best combination of analyzers that don't interfere with each other.

Function Description

Complete the function maximizeProcessingPower in the editor.

maximizeProcessingPower has the following parameter(s):

  1. int processingPower[n]: The processing power of the TikTok video analyzers.

Returns

long: The maximum achievable total video processing power.

👑 Cheers to Tsoppa’s Burgir World Domination! 🍔 👑

1Example 1

Input
processingPower = [1, 3, 9, 2, 3]
Output
16
Explanation
In the original problem source, it says ans is 15, which is incorrect. The correct answer should be 16 since 1 + 3 + 9 + 3 = 16 🐿️

2Example 2

Input
processingPower = [3, 3, 5, 5, 2, 2, 5]
Output
21
Explanation
One of the optimal ways to choose the video analyzers for maximum processing power is to select the analyzers at indices 0, 1, 2, 3, and 6 the sum of capacities is 3 + 3 + 5 + 5 + 5 = 21. Hence, we return 21 🐰

3Example 3

Input
processingPower = [8, 5, 1, 5]
Output
19
Explanation
In this scenario, the processing powers of the TikTok video analyzers are such that all of them can be selected without interference. Hence, the maximum achievable total processing power is 8 + 5 + 1 + 5 = 19 🐝

Constraints

Limits and guarantees your solution can rely on.

  • 1 ≤ n ≤ 10^5
  • 1 ≤ processingPower[i] ≤ 10^5
public long maximizeProcessingPower(int[] processingPower) {
  // write your code here
}
Input

processingPower

[1, 3, 9, 2, 3]

Output

16

Sign in to submit your solution.