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 97b5162

Browse files
Update 593._Valid_Square.md
1 parent 06710a9 commit 97b5162

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎docs/Leetcode_Solutions/593._Valid_Square.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,19 @@ class Solution(object):
7979
return True
8080
return False
8181
```
82+
83+
## Follow up
84+
85+
如果给一个列表的点,返回一共能组成多少个正方形。input里面可能有重复的点
86+
87+
88+
开始我很sb的想着4 个 for loop取得4个点,然后用上面的函数判断是否可以组成正方形,最后叠加结果并且返回
89+
90+
这里感谢微信墨汁大佬的指导,
91+
92+
- 首先将input去重
93+
- 然后可以先将所有点放到一个字典里面去
94+
- 然后我们用2个for loop去确定好2个点,根据正方形的性质我们就可以自己算出正方形的另外两个点了
95+
- 随后我们判断这两个点是否在我们的字典里面
96+
97+
这样我们最终的时间复杂度是O(N^2),时间复杂度是O(N),完美!!

0 commit comments

Comments
(0)

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