Reported September 2026
Tekiondynamic programming

Dungeon Game

Reported by candidates from Tekion's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Tekion OA. Under 2s to a working solution.
Founder's read

The Tekion OA reported in September 2026 is Dungeon Game, and the hinted pattern says simulation, but simulating forward is the trap. The solution hinges on a 2D DP table, filled backward from the princess's cell. If you've got an invite and 24-72 hours, this is the one to lock in. The grid is up to 200 by 200, so brute-force path search won't survive. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the backward DP is short enough to own before you start.

The problem

A knight starts at the top-left cell of a nonempty rectangular matrix dungeon and must reach the bottom-right cell. From any cell, the knight may move only one step right or one step down.
Each cell contains an integer. A negative value is damage taken on entry, while a nonnegative value is health recovered on entry. The knight's health is an integer that must stay at least 1 after entering every cell, including the start and destination.
Return the minimum initial health that lets the knight reach the destination by choosing an optimal path.

Function
calculateMinimumHP(dungeon: int[][]) → int

Examples
Example 1
dungeon = [[-2,-3,3],[-5,-10,1],[10,30,-5]]
return = 7
The path -2, -3, 3, 1, -5 is survivable with initial health 7. No smaller initial value can survive an optimal route.
Example 2
dungeon = [[0]]
return = 1
The only cell causes no damage, but health must remain positive, so the minimum initial health is 1.

Constraints
1 <= dungeon.length, dungeon[i].length <= 200
dungeon is rectangular.
-1000 <= dungeon[i][j] <= 1000

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to work in reverse. Define dp[i][j] as the minimum health needed when stepping into cell (i,j) to still finish alive. At the bottom-right, dp = max(1, 1 - dungeon[i][j]). Everywhere else, take the smaller of dp[i+1][j] and dp[i][j+1], subtract dungeon[i][j], then clamp to at least 1. The common pitfall is going top-left to bottom-right and tracking the best running sum. That fails because a path with a high total can still dip to zero early, and the minimum prefix matters, not the final sum. Another miss is forgetting the clamp, which lets health go to zero or negative after a big potion. Pad the edges with infinity to skip boundary checks, or use a single row for O(n) space. If you freeze during the live OA, StealthCoder can hand you this recurrence, but you should be able to write it from memory in five minutes.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Dungeon Game cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as dungeon game. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Tekion's OA.

Tekion reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Dungeon Game FAQ

What's the trick to Dungeon Game?+

Go backward. Compute the minimum health needed at each cell by starting from the destination. Each cell needs max(1, min(right, down) - value). Forward DP fails because you must track both the running sum and the lowest dip, and the two conflict.

How hard is this problem really?+

It's rated hard, but only because the backward direction isn't obvious. Once you see it, the code is about ten lines. The Tekion version has the same constraints and examples as the classic, so there are no hidden twists to worry about.

Why not just simulate every path?+

A 200 by 200 grid has an astronomical number of right and down paths. Even with memoization, forward state needs two values. Backward DP collapses each cell to one number, giving O(m*n) time, which is what the constraints demand.

What edge cases should I test?+

Test a single cell like [[0]], which returns 1. Test a single cell with a big potion, which still returns 1. Test all negative cells, and a single row or column. The clamp to 1 is the thing most people forget.

How do I prepare in 48 hours?+

Write the backward DP from scratch twice, once with a full 2D table and once with a rolling 1D row. Run both on the two examples. Then do a couple of other grid DP problems so the fill direction becomes a habit you pick deliberately.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Tekion.

OA at Tekion?
Invisible during screen share
Get it