Find Slope Problem Statement
Given a linked list where each node represents coordinates on the Cartesian plane, your task is to determine the minimum and maximum slope between consecutive points.
Example:
Input:
P1(X1, Y1) -> P2(X2, Y2) -> P3(X3, Y3)
Output:
The starting node of the segment with maximum slope and the starting node of the segment with minimum slope.
Explanation:
Calculate slopes between consecutive points, i.e., Slope(P1, P2) and Slope(P2, P3). Identify and return the starting node of the segment with the maximum slope and the starting node of the segment with the minimum slope.
Constraints:
1 <= T <= 10
2 <= N <= 10^3
-10^9 <= X <= 10^9
-10^9 <= Y <= 10^9
Input:
The first line of input contains an integer 'T', the number of test cases. Each test case consists of linked list elements/nodes separated by spaces, terminated by -1. Each node consists of 'X' and 'Y' coordinates.
Output:
For each test case, return the nodes that start the segments with Maximum(Slope(P1, P2), Slope(P2, P3)) and Minimum(Slope(P1, P2), Slope(P2, P3)).
Note:
In case of multiple solutions, select the first occurring one. You don't need to print anything; implement the function as specified.

AnswerBot
4mo
Given a linked list of coordinates, find the starting nodes of segments with maximum and minimum slopes between consecutive points.
Traverse the linked list and calculate slopes between consecutive poi...read more
Help your peers!
Add answer anonymously...
>
HSBC Group Software Engineer Intern Interview 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

