LeetCodeMetaData / check-if-point-is-reachable.json
DataRepo's picture
Upload part 1 of 2
4097b71 verified
{
"id": 2635,
"name": "check-if-point-is-reachable",
"difficulty": "Hard",
"link": "https://leetcode.com/problems/check-if-point-is-reachable/",
"date": "2023-01-07",
"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`",
"test_case": [
{
"label": "Example 1",
"input": "targetX = 6, targetY = 9",
"output": "false "
},
{
"label": "Example 2",
"input": "targetX = 4, targetY = 7",
"output": "true "
}
],
"constraints": [
"(x, y - x)",
"(x - y, y)",
"(2 * x, y)",
"(x, 2 * y)",
"1 <= targetX, targetY <= 109"
],
"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 ",
"java_template": "class Solution {\n public boolean isReachable(int targetX, int targetY) {\n \n }\n}",
"metadata": {
"func_name": "isReachable"
}
}