Untitled

 avatar
user_1208626
java
5 months ago
466 B
2
Indexable
class Solution {

    public boolean isReachableAtTime(int sx, int sy, int fx, int fy, int t) {

        if (sx == fx && sy == fy) {
            return t != 1;
        } 

        //make sure (sx, sy) is above (or inline) and left (or inline) to (fx,fy)
        if (sx > fx) {
            fx = sx + sx - fx;
        }

        if (sy > fy) {
            fy = sy + sy - fy;
        }
        
        return t >= Math.max(fx - sx, fy - sy);
    }
}
Editor is loading...
Leave a Comment