Maximize Total Memory Points

Problem Overview

  • Reorder n chapters to maximize total memory points while reading all chapters.
  • Input: memory[n] with -10^3 ≤ memory[i] ≤ 10^3; Output: max total as a long integer; 1 ≤ n ≤ 10^5.
  • Context: Amazon Academy Quantum Physics course; reading a chapter adds its points plus all earlier visited ones.
  • From Amazon interviews; a coding interview interview question and optimization problem.

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: