Skip to content

Practice Determine if a Cell Is Reachable at a Given Time

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2849
LeetCode Problem

Determine if a Cell Is Reachable at a Given Time

Problem Statement

You are given four integers sx, sy, fx, fy, and a non-negative integer t. In an infinite 2D grid, you start at the cell (sx, sy). Each second, you must move to any of its adjacent cells. Return true if you can reach cell (fx, fy) after exactly t seconds, or false otherwise. A cell's adjacent cells are the 8 cells around it that share at least one corner with it. You can visit the same cell several times.

Source: Determine if a Cell Is Reachable at a Given Time on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
sx = 2, sy = 4, fx = 7, fy = 7, t = 6
Output
true

# Example 2

Input
sx = 3, sy = 1, fx = 7, fy = 3, t = 3
Output
false

Constraints

1 <= sx, sy, fx, fy <= 10^9
0 <= t <= 10^9

Related LeetCode Problems

Practice more problems similar to Determine if a Cell Is Reachable at a Given Time.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.