Regulate Temperatures

Problem Overview

  • Compute the minimum actions to make all core temperatures zero using three moves: decrease any prefix by 1, decrease any suffix by 1, or increase all cores by 1.
  • Input: integer array temperature of size n; Output: long for the minimum number of actions.
  • Context: regulating CPU core temperatures in a computer system.
  • This problem is from Amazon interviews and is a common coding interview 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: