Skip to content

Commit 5435a70

Browse files
committed
Runtime: 658 ms (Top 42.61%) | Memory: 16 MB (Top 39.48%)
1 parent 1217e7e commit 5435a70

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

scripts/algorithms/D/Detect Squares/Detect Squares.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Runtime: 658 ms (Top 42.61%) | Memory: 16 MB (Top 39.48%)
12
"""
23
Store every points and number of their appearance
34
Group the points by their x value
@@ -9,10 +10,9 @@
910
1011
Use the decided side length to calculate p3 and p4, see if they are in the dict. If do, add product of their appearances.
1112
12-
p3 p2 p3`
13+
p3 p2 p3`
1314
14-
15-
p4 p1 p4`
15+
p4 p1 p4`
1616
1717
Notice that p3 and p4 can be on both left side and right side of side (p2,p1)
1818
@@ -48,11 +48,10 @@ def count(self, p1: List[int]) -> int:
4848
p3=(x1+b,y2)
4949
p4=(x1+b,y1)
5050
if p3 in self.pts and p4 in self.pts:
51-
res+=self.pts[p2]*self.pts[p3]*self.pts[p4]
51+
res+=self.pts[p2]*self.pts[p3]*self.pts[p4]
5252
return res
5353

54-
5554
# Your DetectSquares object will be instantiated and called as such:
5655
# obj = DetectSquares()
5756
# obj.add(point)
58-
# param_2 = obj.count(point)
57+
# param_2 = obj.count(point)

0 commit comments

Comments
 (0)