1.两数之和
暴力:双循环
正解:
哈希表<值,下标>
先find找不到再insert,保证不会和自己匹配。
1 |
|
链接:https://leetcode.cn/problems/two-sum/solutions/434597/liang-shu-zhi-he-by-leetcode-solution/
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Xielei's Blog!
暴力:双循环
正解:
哈希表<值,下标>
先find找不到再insert,保证不会和自己匹配。
1 |
|
链接:https://leetcode.cn/problems/two-sum/solutions/434597/liang-shu-zhi-he-by-leetcode-solution/