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
The problem involves determining if it is possible to reach a destination point from a source point using specified moves.
Iterate through each test case and check if destination is reachable from sour...read more
Help your peers!
Add answer anonymously...
Tata CLiQ Software Developer interview questions & answers
A Software Developer was asked Q. Reach the Destination Problem Statement You are given a source point (sx, sy) an...read more
A Software Developer was asked Q. Cycle Detection in a Singly Linked List Determine if a given singly linked list ...read more
A Software Developer was asked Q. Pythagorean Triplets Detection Determine if an array contains a Pythagorean trip...read more
Popular interview questions of Software Developer
A Software Developer was asked Q1. Reach the Destination Problem Statement You are given a source point (sx, sy) an...read more
A Software Developer was asked Q2. Cycle Detection in a Singly Linked List Determine if a given singly linked list ...read more
A Software Developer was asked Q3. Pythagorean Triplets Detection Determine if an array contains a Pythagorean trip...read more
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

