Problem · Dynamic Programming
Efficient Deployments
Learn this problemProblem statement
A supercomputer has n processors arranged in a row. Processors are deployed one at a time in any order.
For processor i, its efficiency is:
no_adjacent[i]when neither adjacent processor was deployed earlier,one_adjacent[i]when exactly one adjacent processor was deployed earlier,both_adjacent[i]when both adjacent processors were deployed earlier.
The first and last processors have only one adjacent processor. Return the maximum total efficiency over all deployment orders.
Function
getMaximumSum(no_adjacent: int[], one_adjacent: int[], both_adjacent: int[]) → longExamples
Example 1
no_adjacent = [1, 2, 3, 4]one_adjacent = [4, 4, 2, 1]both_adjacent = [0, 1, 1, 0]return = 14Deploy processors in the order 4 -> 3 -> 2 -> 1. Their efficiencies are 4, 2, 4, and 4, for a total of 14.
The older source rendering lists 13, but its displayed addition substitutes 3 for one_adjacent[3] = 2. Applying the stated rules and arrays gives 14.
Constraints
2 <= n <= 10^5no_adjacent.length == one_adjacent.length == both_adjacent.length == n1 <= no_adjacent[i], one_adjacent[i], both_adjacent[i] <= 10^9
More Snowflake problems
- Closest Target CharacterPHONE SCREEN · Seen Jul 2026
- Horizontal Pod AutoscalerSeen Jul 2026
- Minimum HeightOA · Seen Jul 2026
- Vowel SubstringSeen Jun 2026
- String Formation (Also for AI/ML Software Engineer Intern :)OA · Seen Jun 2026
- Character Frequencies Across Nested String ListsPHONE SCREEN · Seen Jun 2026
- Character Frequencies Across StringsPHONE SCREEN · Seen Jun 2026
- Top Two Users by Total Purchase AmountPHONE SCREEN · Seen Jun 2026