FastPrepMaximum Sum of Heights
Problems/Maximum Sum of Heights

Maximum Sum of Heights

Virtu Financial logoVirtu Financial● HardFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report names the tower-construction exercise. Our version uses the usual per-index caps, the mountain condition, and the goal of the maximum sum for that task.

You are given positive maximum heights maxHeights. Choose a positive height for every index so that height[i] <= maxHeights[i].

The resulting array must be mountain-shaped: for some peak index, heights do not decrease before the peak and do not increase after it.

Return the maximum possible sum of the chosen heights.

Function

maximumSumOfHeights(maxHeights: List<Integer>) → long

Examples

Example 1

maxHeights = [5,3,4,1,1]return = 13

Choosing [5,3,3,1,1] forms a mountain with sum 13.

Example 2

maxHeights = [6,5,3,9,2,7]return = 22

Using index 3 as the peak allows the mountain [3,3,3,9,2,2], whose sum is 22.

Constraints

  • 1 <= maxHeights.length <= 100000
  • 1 <= maxHeights[i] <= 10^9

More Virtu Financial Online Assessment questions

  • Count Substrings With Identical CharactersOA · Seen Oct 2026
  • HexSpeakOA · Seen Oct 2026
  • Maximum Apples That Fit in a BoxOA · Seen Oct 2026
  • Minimum Steps to a Fibonacci NumberOA · Seen Oct 2026
  • Stabilize Student Test ScoresOA · Seen Oct 2026
  • Maximum Barbell WeightOA · Seen Sep 2026
  • Optimal Account BalancingOA · Seen Sep 2026
  • Reaching PointsOA · Seen Sep 2026
  • Banking Transaction ExceptionsOA · Seen Aug 2026
  • FIX Message ReconciliationOA · Seen Aug 2026

Similar questions at other companies

  • Trapping Rain WaterGoogle · OAGoogle interview questions
  • Alternating Jumps to the Last IndexExpedia · OAExpedia interview questions
  • Trapping Rain WaterMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Maximum Sum of HeightsAmazon · ONSITE INTERVIEW
  • Rain Kept Between WallsDocuSign · PHONE SCREENDocuSign interview questions
  • Rain Water Held Between BarsAdobe · PHONE SCREENAdobe interview questions
  • Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
  • Largest Consistent Visiting GroupAuxoAI · OA
  • Delete K Subsets for Maximum ScoreRubrik · OARubrik interview questions
  • Most Segments That Sort the ArrayRippling · OARippling interview questions

Virtu Financial interview experiences

  • Virtu Financial New Grad Quant Trader HR Screen: 1 Experience
  • Virtu Financial Quant Trading Intern Onsite: 1 Experience
All Virtu Financial interview questionsSee Virtu Financial hiring insights
Saved
class Solution {
    public long maximumSumOfHeights(List<Integer> maxHeights) {
        // Write your code here.
    }
}
Checking account…