Valid Square
From LeetCode. Square from 4 points. Solve the geometry problem "Valid Square".
Examples
Input: [1,2,3]
Output: 0
Input: [2,3,4]
Output: 0
Hints
In a square, all four sides are equal and both diagonals are equal. Compute all 6 pairwise squared distances between the 4 points.
Sort the 6 squared distances. A valid square must have the smallest 4 equal (the sides) and the largest 2 equal (the diagonals), with the diagonal strictly larger than the side.
Use squared distances to avoid floating-point precision. Return false immediately if any two points coincide (distance == 0).
Valid Square
**From LeetCode.** Square from 4 points. Solve the geometry problem "Valid Square".