Company: Intuit_31july

Difficulty: medium

Problem Statement

Tax Collector's Survival A tax collector must travel through an N × M dungeon to collect revenue records. Each cell contains an integer that changes the collector's health points (HP): A positive value increases HP. A negative value decreases HP. Zero does not change HP. The collector starts at the top-left cell (0, 0) and must reach the bottom-right cell (N - 1, M - 1) . At every step, the collector may move only right or down. The collector's HP must remain strictly greater than zero at every cell visited, including the starting and destination cells. Determine the minimum initial HP required to guarantee survival until the destination. Input The first line contains an integer N , the number of rows. The second line contains an integer M , the number of columns. The next N lines each contain M space-separated integers describing the dungeon grid. Constraints 1 ≤ N, M ≤ 200 -1000 ≤ dungeon[i][j] ≤ 1000 Use integer arithmetic; the answer fits in a signed 64-bit integer.

More Intuit_31july OA questionsInterview experiences