Skip to content

Commit 65f9add

Browse files
authored
Create Determine if a Cell Is Reachable at a Given Time.java
1 parent cbdf34b commit 65f9add

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public boolean isReachableAtTime(int sx, int sy, int fx, int fy, int t) {
3+
int xDiff = Math.abs(sx - fx);
4+
int yDiff = Math.abs(sy - fy);
5+
if (xDiff == 0 && yDiff == 0 && t == 1) {
6+
return false;
7+
}
8+
return (Math.min(xDiff, yDiff) + Math.abs(xDiff - yDiff)) <= t;
9+
}
10+
}

0 commit comments

Comments
 (0)