File size: 3,491 Bytes
24e07f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
    "id": 2635,
    "name": "check_if_point_is_reachable",
    "difficulty": "Hard",
    "link": "https://leetcode.com/problems/check-if-point-is-reachable/",
    "date": "2023-01-07 00:00:00",
    "task_description": "There exists an infinitely large grid. You are currently at point `(1, 1)`, and you need to reach the point `(targetX, targetY)` using a finite number of steps. In one **step**, you can move from point `(x, y)` to any one of the following points: `(x, y - x)` `(x - y, y)` `(2 * x, y)` `(x, 2 * y)` Given two integers `targetX` and `targetY` representing the X-coordinate and Y-coordinate of your final position, return `true` _if you can reach the point from_ `(1, 1)` _using some number of steps, and _`false`_ otherwise_. **Example 1:** ``` **Input:** targetX = 6, targetY = 9 **Output:** false **Explanation:** It is impossible to reach (6,9) from (1,1) using any sequence of moves, so false is returned. ``` **Example 2:** ``` **Input:** targetX = 4, targetY = 7 **Output:** true **Explanation:** You can follow the path (1,1) -> (1,2) -> (1,4) -> (1,8) -> (1,7) -> (2,7) -> (4,7). ``` **Constraints:** `1 <= targetX, targetY <= 109`",
    "public_test_cases": [
        {
            "label": "Example 1",
            "input": "targetX = 6, targetY = 9",
            "output": "false "
        },
        {
            "label": "Example 2",
            "input": "targetX = 4, targetY = 7",
            "output": "true "
        }
    ],
    "private_test_cases": [
        {
            "input": [
                303660259,
                537982881
            ],
            "output": true
        },
        {
            "input": [
                382325806,
                733120976
            ],
            "output": true
        },
        {
            "input": [
                210576177,
                530284179
            ],
            "output": false
        },
        {
            "input": [
                577023801,
                854345261
            ],
            "output": true
        },
        {
            "input": [
                793570509,
                391886469
            ],
            "output": false
        },
        {
            "input": [
                336580977,
                487441233
            ],
            "output": false
        },
        {
            "input": [
                697974041,
                697734349
            ],
            "output": true
        },
        {
            "input": [
                596465905,
                19353105
            ],
            "output": false
        },
        {
            "input": [
                391568324,
                13283871
            ],
            "output": true
        },
        {
            "input": [
                102819043,
                988910507
            ],
            "output": true
        }
    ],
    "haskell_template": "isReachable :: Int -> Int -> Bool\nisReachable targetX targetY ",
    "ocaml_template": "let isReachable (targetX: int) (targetY: int) : bool =  ",
    "scala_template": "def isReachable(targetX: Int,targetY: Int): Boolean = { \n    \n}",
    "java_template": "class Solution {\n    public boolean isReachable(int targetX, int targetY) {\n        \n    }\n}",
    "python_template": "class Solution(object):\n    def isReachable(self, targetX, targetY):\n        \"\"\"\n        :type targetX: int\n        :type targetY: int\n        :rtype: bool\n        \"\"\"\n        "
}