Minimum Energy Cost

Problem Overview

  • Minimize total energy to collect all N bags by taking from the left or right; each pick costs WiX (left) or WiY (right) plus El/Er if the same side is chosen consecutively.
  • Input: N, X, Y, El, Er, and N weights Wi; Output: the minimum energy cost.
  • Context: sequential resource collection with side-dependent costs and penalties for repeated side use.
  • Asked in Amazon interviews; a classic 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: