Skip to content

Commit b24ed76

Browse files
authored
Create 2849. Determine if a Cell Is Reachable at a Given Time (#342)
2 parents 280576c + 4f3ca02 commit b24ed76

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
bool isReachableAtTime(int sx, int sy, int fx, int fy, int t) {
4+
if(sx == fx && sy == fy){
5+
if(t==1)return false;
6+
return true;
7+
}
8+
int x = abs(sx-fx),y = abs(sy-fy);
9+
if(max(x,y)>t){
10+
return false;
11+
}
12+
return true;
13+
}
14+
};

0 commit comments

Comments
 (0)