Problem Solving/LeetCode
2023.11.08 Today's Challenge
fabichoi
2023. 11. 8. 23:45
Determine if a Cell Is Reachable at a Given Time - LeetCode
Can you solve this real interview question? Determine if a Cell Is Reachable at a Given Time - 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 a
leetcode.com
x, y 축에 대해 간단한 이해만 있으면 되는 문제
class Solution:
def isReachableAtTime(self, sx: int, sy: int, fx: int, fy: int, t: int) -> bool:
w, h = abs(sx - fx), abs(sy - fy)
if w == 0 and h == 0 and t == 1:
return False
return t >= max(w, h)
반응형