P14284 [GeeksforGeeks] Check if given four points form a square3026
普及-
题目描述

Given coordinates of four points in a plane. Find if the four points form a square or not.
Example 1:
Input:
points=(0,0),(0,1),(1,0),(1,1)
Output:
1
Explanation:
These points form a square.
Example 2:
Input:
points=(0,0),(1,1),(1,0),(0,2)
Output:
0
Explanation:
These four points do not form a square.
Your Task:
You don't need to read input or print anything.Your Task is to complete the function fourPointSquare() which takes a 2D array of dimensions 4x2 which contains the cordinates of the four points and returns 1 if they form a square.Otherwise it returns 0.

Expected Time Complexity:O(1)
Expected Space Complexity:O(1)

Constraints:
0<=X-cordinate,Y-cordinate<=10^{5}

输入格式

见题面

输出格式

见题面

样例输入
points=(0,0),(0,1),(1,0),(1,1)
样例输出
1