We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 710d5c5 commit 3ff5b34Copy full SHA for 3ff5b34
.gitattributes
@@ -0,0 +1,3 @@
1
+* linguist-vendored
2
+solutions/* linguist-vendored=false
3
+solutions/*.json linguist-vendored
solutions/001.two-sum/post.md
@@ -0,0 +1,6 @@
+# 001.two-sum
+这道题是我在`Leetcode`刷的第一道题,最开始是使用暴力枚举法枚举所有情况,算法复杂度是`O(n)`,很显然,最后超时了。考虑到`Hash Map`的查找的算法复杂度是`O(1)`,这道题便使用了`Hash Map`的解法。
+
4
+我遍历一次整个数组,遍历到的每个`item`,首先去查`Hash Map`,如果没有,则把它的`index`放进`Hash Map`中存储,之后的遍历中,一旦它的相反数出现,便可以找到两个相加的`0`的数了。
5
6
+这样我们的算法复杂度变为`O(n)`。
0 commit comments