Tap here to switch tabs
Problem
Submissions

Problem: Maximum Calories Burnt from Jumps

Try to solve the Maximum Calories Burnt from Jumps problem.

Statement

You are given an integer array heights of length n, where heights[i] represents the height of the object at index i.

You start on the ground at height 00. You must visit every object in heights exactly once by jumping from one object to another in any order of your choice.

When jumping from a height uu to a height vv, the calories burnt equal (u−v)2(u - v)^2.

Return the maximum total calories that can be burnt after visiting all objects.

Constraints:

  • 1≤1 \leq n ==== heights.length ≤105\leq 10^5

  • 1≤1 \leq heights[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Calories Burnt from Jumps

Try to solve the Maximum Calories Burnt from Jumps problem.

Statement

You are given an integer array heights of length n, where heights[i] represents the height of the object at index i.

You start on the ground at height 00. You must visit every object in heights exactly once by jumping from one object to another in any order of your choice.

When jumping from a height uu to a height vv, the calories burnt equal (u−v)2(u - v)^2.

Return the maximum total calories that can be burnt after visiting all objects.

Constraints:

  • 1≤1 \leq n ==== heights.length ≤105\leq 10^5

  • 1≤1 \leq heights[i] ≤105\leq 10^5