Super simple solution using distance in python


  • 0
    M

    def distance(p1, p2):
    return pow(p1[0]-p2[0], 2) + pow(p1[1]-p2[1], 2)

        mapping = {}
        mapping[distance(p1,p2)] = 1
        mapping[distance(p1,p3)] = 1
        mapping[distance(p1,p4)] = 1
        if 0 in mapping or len(mapping) != 2:
            return False
        
        mapping[distance(p2,p3)] = 1
        mapping[distance(p2,p4)] = 1
        if len(mapping) != 2:
            return False
        
        mapping[distance(p3,p4)] = 1
        if len(mapping) != 2:
            return False
        
        return True

  • 0
    Y

    What a..........


  • 0
    M

    2333________


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.