Search⌘ K
AI Features

Dungeon Game

Explore dynamic programming techniques to determine the minimum initial health a knight needs to safely rescue a princess in a dungeon grid. Understand how to navigate cells with demons and magic orbs while ensuring the knight's health never drops to zero or below during the journey.

Statement

A group of demons has captured a princess and locked her in the bottom-right corner of a dungeon. The dungeon is represented as a 2D grid of size m×nm × n, where each cell contains an integer value that affects the knight’s health.

The knight, starting in the top-left corner of the grid, must travel through the dungeon to rescue the princess.
He can move only to the right or downward at each step.

  • If a cell contains a negative integer, it represents a demon that decreases the knight’s health.

  • If a cell contains zero, it is an empty room with no effect. ...