Find Maximum Calories

Problem Overview

  • Find the maximum total calories by ordering jumps to visit each stone exactly once; calories for a jump from i to j are (height[i] - height[j])^2, starting from ground (0) with no return and allowing jumps between any stones.
  • Input: array height of n stones; Output: a long representing the maximum calories; Constraints: 1 ≤ n ≤ 1e5, 1 ≤ height[i] ≤ 46340.
  • Real-world context: Amazon fitness tracker jumping exercise session.
  • From Amazon interviews; a coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: