Convex Hull | Practice | GeeksforGeeks

Convex Hull of a set of points, in 2D plane, is a convex polygon with minimum area such that each point lies either on the boundary of polygon or inside it. Now given a set of points the task is to find the convex hull of points.
 
Example 1:
Input: points_list = {{1,2},{3,1},{5,6}}
Output: {{1,2},{3,1},{5,6}}

Example 2:
Input : points_list = {{5,1},{4,4},{1,2}}
Output: {{1,2},{4,4},{5,1}}

 
Your Task:
You don't need to read or print anything. Your task is to complete the function FindConvexHull() which takes points_list as input parameter and returns Convex Hull of given points in a list. If not possible returns a list containing -1.
 
Expected Time Complexity: O(nlog(n))
Expected Space Complexity: O(n) where n = total no. of points
 
Constraints:
1 <= n <= 104
-105 <= x, y <= 105
0
Mozammel Hossen1 year ago
Mozammel Hossen
Why it is giving WA?
My Code: https://paste.ubuntu.com/p/...
Input:12941 1 23 32 46 26 36 41 15 36 39 40 7 48 14 12 12 39 34 37 38 9 16 47 37 9 32 31 26 35 40 16 37 40 44 1 48 22 34 39 49 10 41 16 49 36 45 44 43 25 21 48 7 37 3 30 15 1
Correct Output:3 30, 7 48, 15 1, 21 48, 44 1, 45 44, 49 10, 49 36
My Output:3 30, 7 48, 15 1, 21 48, 41 1, 44 1, 45 44, 49 10, 49 36
0
rahul sharma2 years ago
rahul sharma
for sample test case161 1 2 2 2 0 2 4 3 3 4 2
The accepted solutions i tried ere does not consider 3,3 as part of output and those are accepted but 3,3 must be part of solution.what did i miss
0
anand verma2 years ago
anand verma
Input:14778 887 794 916 387 336 650 493 363 422 691 28 764 60 541 927 173 427 212 737 568 369 783 430 863 531 68 124
Its Correct output is:68 124, 212 737, 541 927, 691 28, 764 60, 794 916, 863 531
And Your Code's output is:68 124, 212 737, 541 927, 794 916, 863 531, 764 60, 691 28what's the problem here i'm using graham scan please helpthnx in advance
0
shivam kumar2 years ago
shivam kumar
https://practice.geeksforge...
if it can help, considered co-linear case.
0
Sunil Aditya2 years ago
Sunil Aditya
my pyhton 3 code https://ide.geeksforgeeks.o...there are two wrong test acse31 11 2 1 1and 41 1 1 23 43 4so use try except to handle it
0
Prashant Singh2 years ago
Prashant Singh
What wrong in my output,I did run this input to geeks provided code which is giving output similar to my codeInput:2529 23 33 47 16 20 9 25 49 40 40 23 8 23 15 38 10 30 39 48 18 44 10 13 7 31 10 47 48 48 6 15 46 30 45 3 30 48 36 30 25 22 23 21 38 45 26 43 5 27
Its Correct output is:5 27, 6 15, 10 13, 10 47, 30 48, 45 3, 48 48, 49 40
And Your Code's output is:5 27, 6 15, 10 13, 10 47, 30 48, 39 48, 45 3, 48 48, 49 40@shameek_agarwal:disqus
0
aniket poddar2 years ago
aniket poddar
https://ide.geeksforgeeks.o...
Here why are we not considering co-linear points
0
Vidit Gupta2 years ago
Vidit Gupta
Code working fine while compiling, but getting the below error while submitting code. Plz help @quandray:disqus.
Runtime Error:Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2 at GFG.main(File.java:35)
https://ide.geeksforgeeks.o...
-1
Shameek Agarwal2 years ago
Shameek Agarwal
Graham scan workingmy code->https://ideone.com/yeCEga
0
yash2 years ago
yash
https://ide.geeksforgeeks.o...
getting segmentation fault
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.