
Asked in American Express
Reach the Destination Problem Statement
You are given a source point (sx, sy) and a destination point (dx, dy). Determine if it is possible to reach the destination point using only the following valid moves:
- (a, b) -> (a + b, b)
- (a, b) -> (a, a + b)
Input:
The input consists of:
The first line contains an integer ‘T’, the number of test cases. Each test case consists of a single line with four space-separated integers sx, sy, dx, dy representing the source point (sx, sy) and the destination point (dx, dy).
Output:
For each test case, return the boolean value true if it is possible to reach the destination point from the source point using only the specified moves, otherwise return false. The output for each test case should be on a separate line.
Example:
Input:
1
1 1 3 5
Output:
true
Explanation:
You can move from (1, 1) -> (1, 2) -> (3, 2) -> (3, 5), hence the destination is reachable.
Constraints:
- 1 <= T <= 100
- 1 <= x, y <= 3000
Note: You do not need to print anything. Implement the function to solve the problem.

AnswerBot
4mo
Determine if it is possible to reach the destination point from the source point using specified moves.
Use depth-first search (DFS) to explore all possible paths from source to destination.
Keep track ...read more
Help your peers!
Add answer anonymously...
Top Full Stack Developer Interview Questions Asked at American Express
Q. Buy and Sell Stock Problem Statement Imagine you are Harshad Mehta's friend, and...read more
Q. Circular Move Problem Statement You have a robot currently positioned at the ori...read more
Q. Count Pairs with Given Sum Given an integer array/list arr and an integer 'Sum',...read more
Interview Questions Asked to Full Stack Developer at Other Companies
Top Skill-Based Questions for American Express Full Stack Developer
Web Development Interview Questions and Answers
250 Questions
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
JavaScript Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

