JS Solution 992ms


  • 0
    S
    var numberOfBoomerangs = function(points) {
    let result = 0;
    points.forEach((i)=> {
        let distMap = {};
        points.forEach((j)=> {
            if(i!==j) {
                let dist = (i[0]-j[0])*(i[0]-j[0]) + (i[1]-j[1])*(i[1]-j[1]);
                let prevDist = distMap[dist] || 0;
                result += 2*prevDist;
                distMap[dist] = prevDist+1;
            }
        });
    });
    return result;
    

    };


Log in to reply
 

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