You are given an array ‘POINTS’ of size ‘N’. Each element of ‘POINTS’ contains two integers, ‘[X, Y]’ representing a point on the cartesian plane. These points, when joined sequentially, form a polygon. The task is to find if this polygon is convex (Convex polygon).
Example:‘POINTS’ = [ [0, 0], [5, 0], [5, 5], [0, 5] ], ‘N’ = 4.

As the given polygon is a convex polygon, you should return ‘True’ as the answer.
Note:
1. The polygon formed by the given points is always a Simple polygon, i.e., exactly two edges intersect at each vertex, and the edges otherwise don’t intersect each other.
2. All the given points are unique.
The first line of input contains an integer ‘T’ which denotes the number of test cases. Then, the ‘T’ test cases follow.
The first line of each test case contains an integer ‘N’ denoting the size of the array ‘POINTS’. Then, ‘N’ lines follow.
Each line contains two integers, ‘X’ and ‘Y’, representing an element in the array ‘POINTS’.
Output format:
For every test case, if the given polygon is convex, return ‘True’. Otherwise, return ‘False’.
Note:
You do not need to print anything; it has already been taken care of. Just implement the function.
1 <= T <= 100
1 <= N <= 1000
-10^4 <= Value in each element of ‘POINTS’ <= 10^4
Time limit: 1 second
2
6
0 0
10 0
7 5
10 10
0 10
2 5
5
-10 5
-10 10
-5 15
0 15
0 5
False
True
Test Case 1:

The interior angle at the vertex ‘(2, 5)’ is more than 180 degrees, so the given polygon is not convex. Thus, you should return ‘False’ as the answer.
Test Case 2:

As the given polygon is a convex polygon, you should return ‘True’ as the answer.
2
5
0 0
5 0
5 5
2 8
0 5
5
5 0
15 0
15 10
5 10
10 5
True
False
For any edge, what should be the positions of every vertex w.r.t. it?
For any edge ‘E’ in a convex polygon, every vertex ‘V’ should be either at one side of it (above/below) or on it. Consider the following two examples:

Let ‘AB’ be the edge between the vertices ‘(A, B)’ and ‘C’ be any vertex.
‘POS = (B.x - A.x) * (C.y - A.y) - (B.y - A.y) * (C.x - A.x)’ (Position of point ‘C’ w.r.t. ‘AB’).
Here, ‘POS’ is the Z-component of the cross-product between the vectors ‘AB’ and ‘AC’. To decide if ‘C’ is below or above ‘AB’:

In other words, ‘POS’ can be:
So, for any edge, if we find two vertices having opposite signs of ‘POS’, then we declare that the polygon is not convex.
Algorithm:
O(N^2), where ‘N’ is the size of the array ‘POINTS’.
There are ‘N’ edges, and for each edge, we iterate through all the ‘N’ vertices. Thus, the time complexity is ‘O(N^2)’.
O(1).
Since we are not using any extra space, space complexity is constant.