![]() |
VOOZH | about |
Given a 2D arraypoint[][] with each row of the form {X, Y}, representing the co-ordinates of a polygon in either clockwise or counterclockwise sequence, the task is to check if the polygon is a convex polygon or not. If found to be true, then print "Yes" . Otherwise, print "No".
In a convex polygon, all interior angles are less than or equal to 180 degrees
Examples:
Input: arr[] = { (0, 0), (0, 1), (1, 1), (1, 0) }
👁 Image
Output: Yes
Explanation:
Since all interior angles of the polygon are less than 180 degrees. Therefore, the required output is Yes.Input : arr[] = {(0, 0), (0, 10), (5, 5), (10, 10), (10, 0)}
👁 Image
Output : No
Explanation:
Since all interior angles of the polygon are not less than 180 degrees. Therefore, the required output is No.
Approach: Follow the steps below to solve the problem:
Below is the implementation of the above approach:
Yes
Time Complexity: O(N)
Auxiliary Space:O(1)