Maximize The Hits

Problem Overview

  • Determine the maximum number of wall hits on a number line given a total energy budget in this simulation problem.
  • Inputs: int[] walls (positions at x+0.5), int[] thickness (wall costs), and int energy; Output: int max hits.
  • Movement costs 1 energy per step; crossing a wall costs its thickness; start at x=0; you can move both directions and re-hit walls.
  • Context: game-like energy management scenario; common coding interview/interview question.
  • This problem was asked in Openai interviews.

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: