Skip to content

Commit 751b0bb

Browse files
committed
docs: 修改第一题的题解文档,作为规范模板。供后续题解文档参考。
1 parent 9531581 commit 751b0bb

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

tips/001/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Solution {
3636
}
3737
}
3838
```
39-
javascript
39+
javascript:
4040
```javascript
4141
var twoSum = function(nums, target) {
4242
for (let i = 0; i < nums.length - 1; i++) {
@@ -71,7 +71,7 @@ class Solution {
7171
## 思路 1
7272

7373
利用 HashMap 作为存储,键为目标值减去当前元素值,索引为值,比如 `i = 0` 时,此时首先要判断 `nums[0] = 2` 是否在 map 中,如果不存在,那么插入键值对 `key = 9 - 2 = 7, value = 0`,之后当 `i = 1` 时,此时判断 `nums[1] = 7` 已存在于 map 中,那么取出该 `value = 0` 作为第一个返回值,当前 `i` 作为第二个返回值,具体代码如下所示。
74-
74+
java:
7575
```java
7676
class Solution {
7777
public int[] twoSum(int[] nums, int target) {
@@ -88,12 +88,9 @@ class Solution {
8888
}
8989
```
9090

91-
9291
## 结语
9392

9493
如果你同我们一样热爱数据结构、算法、LeetCode,可以关注我们 GitHub 上的 LeetCode 题解:[LeetCode-Solution][ls]
9594

96-
97-
9895
[title]: https://leetcode.com/problems/two-sum
9996
[ls]: https://github.com/SDE603/LeetCode-Solution

0 commit comments

Comments
 (0)