Error
|
|
---|---|
@Ibrahim Nash | 6379 |
@blackshadows | 6329 |
@mb1973 | 5358 |
@Quandray | 5231 |
@akhayrutdinov | 5111 |
@saiujwal13083 | 4510 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3522 |
@sushant_a | 3459 |
@verma_ji | 3357 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@ritiksethi21 | 1050 |
@aroranayan999 | 807 |
@RizulBansal | 685 |
@ashishtrehan002 | 538 |
@hemantgarg923 | 528 |
@simrangoyal | 526 |
@ronaldo77 | 520 |
@thanosagain | 505 |
@anishrajan | 505 |
@ssparteek470 | 495 |
@rahul2312 | 491 |
Complete Leaderboard |
Given the coordinates of the endpoints(p1-q1 and p2-q2) of the two line-segments. Check if they intersect or not.
Example 1:
Input:
p1=(1,1)
q1=(10,1)
p2=(1,2)
q2=(10,2)
Output:
0
Explanation:
The two line segments formed
by p1-q1 and p2-q2 intersect.
Example 2:
Input:
p1=(10,0)
q1=(0,10)
p2=(0,0)
q2=(10,10)
Output:
1
Explanation:
The two line segments formed
by p1-q1 and p2-q2 intersect.
Your Task:
You don't need to read input or print anything. Your task is to complete the function doIntersect() which takes the four points as input parameters and returns 1 if the line segments intersect. Otherwise, it returns 0.
Expected Time Complexity:O(1)
Expected Auxillary Space:O(1)
Constraints:
-106<=X,Y(for all points)<=106
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes