Maximize Total Memory Points
Learn this problemProblem statement
FastPrep.io Academy has recently introduced an exciting new course focused on Quantum Physics, providing learners with an opportunity to explore the fascinating world of quantum mechanics and its applications.
The course has n chapters, where the i-th chapter has memory[i] memory points, which a student gains or loses while reading that chapter. The course follows a specific requirement: before studying a chapter, the student must revisit all the previously read chapters.
This means that when reading the chapter placed at position i in the chosen reading order, the student accumulates a total of memory[0] + memory[1] + ... + memory[i] memory points, where the indices refer to the chapters in the order chosen by the student. The total memory points is the sum of the memory points gained while reading each chapter.
Students have the flexibility to read the chapters in any order and aim to maximize their total memory points. The goal is to determine the maximum possible total memory points a student can accumulate while ensuring that all chapters are read at least once.
Your task is to find and return the highest possible total memory points that a student can achieve by choosing the optimal reading order.
Function
maximizeTotalMemoryPoints(memory: int[]) → longExamples
Example 1
memory = [3, 4, 5]return = 26Constraints
1 ≤ n ≤ 10^5-10^3 ≤ memory[i] ≤ 10^3
More Amazon problems
- Drone Delivery RouteOA · Seen Aug 2026
- Package Dependency OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Unfulfilled Customers by Inventory PriorityOA · Seen Aug 2026
- Calculate Beauty ValuesOA · Seen Aug 2026
- Maximize Distance to the Closest Occupied SeatONSITE INTERVIEW · Seen Aug 2026
- Package Delivery SystemOA · Seen Aug 2026
- Select Least Resource TasksOA · Seen Aug 2026
- Maximum Length-K Window Sum over Sparse SegmentsOA · Seen Aug 2026