Find Optimal Input

Problem Overview

  • Find the optimal microwave keypad input minimizing cost for a given target cooking time.
  • Input: targetTime in seconds; Output: integer input value (findOptimalInput).
  • Candidate inputs must be within 10% of target; if costs tie, choose the closest time.
  • Digit sequences are parsed as minutes:seconds per microwave rules (e.g., 999->9m99s, 81->81s, 1221->12m21s).
  • A Google interviews coding interview problem and interview question set in a real-world microwave context.

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: