Company: Amazon

Difficulty: easy

Problem Statement

Amazon Academy has launched a new course on Quantum Physics. The course has n chapters. Chapter i is worth memory[i] memory points, which a student gains (or loses, when the value is negative) while reading that chapter. The course has a strict requirement: in order to study a chapter, the student must revisit all of the chapters that were already read before it. So when a chapter is read, the student gains the sum of the memory points of every chapter read so far, including the chapter being read right now. Concretely, if the student reads the chapters in some order and the memory values in that order are b[0], b[1], ..., b[n-1] , then reading the chapter at position i awards b[0] + b[1] + ... + b[i] memory points, and the total memory points is the sum of the awards of all n readings. The student may read the chapters in any order, and wants to maximize the total memory points. Every chapter must be read exactly once. Find the maximum total memory points the student can score. Input

More Amazon OA questionsInterview experiences