# Valid Square (Leetcode 593)

Problem Link: <https://leetcode.com/problems/valid-square/>

```python
class Solution:
    def validSquare(self, p1: List[int], p2: List[int], p3: List[int], p4: List[int]) -> bool:
        
        def distance(pt1,pt2):
            
            x1=pt1[0], x2=pt2[0]
            y1=pt1[1], y2=pt2[1]
            
            dist = ((x2-x1)^2)+((y2-y1)^2)
            return dist
        
        s=set()
        s.add(dist(p1,p2))
        s.add(dist(p1,p3))
        s.add(dist(p1,p4))
        s.add(dist(p2,p3))
        s.add(dist(p2,p4))
        s.add(dist(p3,p4))
        
        # If dist is 0, two points pverlap
        # If two points overlap, it's not square
        if(0 in s):
            return False
        if(len(s)==2):
            return True
        else:
            return False
        
```
