Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Find a Safe Walk Through a Grid

XPChallenge Points: 20
levelLevel: Medium

You are navigating through a grid of size m x n, represented by cells, where each cell contains either 0 (safe) or 1 (dangerous).

You start at (0, 0) with life points and can move up, down, left, or right.

Each time you enter a dangerous cell (1), your life decreases by 1.
You cannot move once your life drops to 0 or below.

Return true if it’s possible to reach the target (m - 1, n - 1) while still alive, otherwise return false.

Example 1:

Input: cells = [[0,1,0],[0,0,1],[1,0,0]], life = 2

Output: true

Example 2:

Input: cells = [[1,1],[1,0]], life = 1

Output: false

Example 3:

Input: cells = [[0,0,0],[0,1,0],[1,0,0]], life = 2

Output: true

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result