Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6e68112

Browse files
committed
add 447
1 parent e7af6b1 commit 6e68112

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎LeetCodeSolutions/447.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#==================================================
2+
#==> Title:
3+
#==> Author: Zhang zhen
4+
#==> Email: hustmatnoble.gmail.com
5+
#==> GitHub: https://github.com/MatNoble
6+
#==> Date:
7+
#==================================================
8+
9+
10+
from typing import List
11+
from collections import Counter
12+
class Solution:
13+
def numberOfBoomerangs(self, points: List[List[int]]) -> int:
14+
def dis(a, b):
15+
return (a[0]-b[0])**2+(a[1]-b[1])**2
16+
count = 0
17+
for a in points:
18+
dis_ = []
19+
for b in points:
20+
dis_.append(dis(a, b))
21+
dict = Counter(dis_)
22+
for val in dict.values():
23+
if val > 1:
24+
count += val * (val-1)
25+
return count
26+
27+
mat = Solution()
28+
points = [[1,1]]
29+
points = [[0,0],[1,0],[2,0]]
30+
# points = [[1,1],[2,2],[3,3]]
31+
mat.numberOfBoomerangs(points)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /