Skip to content

update #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3,887 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3887 commits
Select commit Hold shift + click to select a range
77dbd63
982 accepted. 1260ms
aQuaYi May 25, 2019
f8f4293
982 删除了 if 语句
aQuaYi May 25, 2019
6cf7207
982 finish, 36ms
aQuaYi May 25, 2019
938037c
更新 README.md
aQuaYi May 25, 2019
7f7d1a8
983 added
aQuaYi May 28, 2019
1481e37
983 doing
aQuaYi May 28, 2019
6fb2999
983 wrong answer
aQuaYi May 28, 2019
19f4603
983 wrong answer
aQuaYi May 28, 2019
4799ebf
983 finish
aQuaYi May 28, 2019
b2ec701
更新 README.md
aQuaYi May 28, 2019
9ae7cc9
986 added
aQuaYi May 29, 2019
4621027
983 accepted. 72ms, faster than 7.79%
aQuaYi May 29, 2019
990466e
986 accepted. 64ms
aQuaYi May 29, 2019
5bd70d4
986 finish
aQuaYi May 29, 2019
7f2acfb
更新 README.md
aQuaYi May 29, 2019
e20d3fe
983 100% coverage
aQuaYi May 30, 2019
09b8981
987 added
aQuaYi May 30, 2019
087a625
987 wrong answer
aQuaYi May 30, 2019
32a11d2
987 accepted. 0ms
aQuaYi May 30, 2019
7f661c7
987 finish
aQuaYi May 30, 2019
96c4fde
更新 README.md
aQuaYi May 30, 2019
11d02ee
988 added
aQuaYi May 31, 2019
588b00c
988 accepted. 8ms, faster than 16.36%
aQuaYi May 31, 2019
c6dca0a
988 wrong answer
aQuaYi May 31, 2019
b8c5235
988 test pass
aQuaYi May 31, 2019
73c8a5e
988 finish
aQuaYi May 31, 2019
1388572
更新 README.md
aQuaYi May 31, 2019
cdbae52
988 add test case
aQuaYi May 31, 2019
1b8b0ab
990 added
aQuaYi Jun 1, 2019
522a372
990 finish
aQuaYi Jun 1, 2019
8c6cc38
990 finish
aQuaYi Jun 1, 2019
963be4e
更新 README.md
aQuaYi Jun 1, 2019
27309cb
991 added
aQuaYi Jun 1, 2019
9ca1e89
991 wrong answer
aQuaYi Jun 1, 2019
996b121
991 wrong answer
aQuaYi Jun 1, 2019
d2e3ae1
991 accepted. 0ms
aQuaYi Jun 1, 2019
5297775
991 accepted.
aQuaYi Jun 1, 2019
a4d344b
更新 README.md
aQuaYi Jun 1, 2019
f21208d
992 added
aQuaYi Jun 1, 2019
360ae72
992 test fail
aQuaYi Jun 1, 2019
e3095c5
992 test fail
aQuaYi Jun 1, 2019
9945ac3
992 wrong answer
aQuaYi Jun 1, 2019
f11b05d
992 Limit Time Exceed
aQuaYi Jun 1, 2019
b68826d
992 finish
aQuaYi Jun 1, 2019
a16ef1f
更新 README.md
aQuaYi Jun 1, 2019
8d145a2
更新 README.md
aQuaYi Jun 1, 2019
bf24ab9
998 added
aQuaYi Jun 2, 2019
87f850d
998 finish
aQuaYi Jun 2, 2019
fa6f0b0
更新 README.md
aQuaYi Jun 2, 2019
a13c033
995 accepted. 1200ms, faster than 8.7%
aQuaYi Jun 2, 2019
13ea1e1
995 add test case
aQuaYi Jun 2, 2019
ef34c9b
995 accepted. 96ms, faster than 95.65%
aQuaYi Jun 2, 2019
e48973b
995 accepted.
aQuaYi Jun 2, 2019
d2960ab
995 finish
aQuaYi Jun 2, 2019
8e8bace
更新 README.md
aQuaYi Jun 2, 2019
7a6cd0a
996 added
aQuaYi Jun 2, 2019
5e4295d
996 Limit Time Exceeded.
aQuaYi Jun 2, 2019
de037b3
996 accepted. 344ms
aQuaYi Jun 2, 2019
8de4c3f
996 finish
aQuaYi Jun 2, 2019
9ea2ed2
更新 README.md
aQuaYi Jun 2, 2019
8cb9beb
1000 added
aQuaYi Jun 3, 2019
55527b1
1000 added
aQuaYi Jun 3, 2019
0b6fe32
1000 doing
aQuaYi Jun 3, 2019
82c2c60
1000 fail
aQuaYi Jun 3, 2019
cdec39f
1000 finish
aQuaYi Jun 3, 2019
2226ad5
更新 README.md
aQuaYi Jun 3, 2019
f5987a9
1000 添加了注释
aQuaYi Jun 4, 2019
462b6e9
1001 wrong answer
aQuaYi Jun 4, 2019
4f8a7fa
1001 accepted. 352ms
aQuaYi Jun 4, 2019
d0619c0
1001 done
aQuaYi Jun 4, 2019
54747e7
更新 README.md
aQuaYi Jun 4, 2019
6f2700b
1001 add commit
aQuaYi Jun 4, 2019
2d454bc
1003 accepted. 4ms
aQuaYi Jun 5, 2019
4228595
1003 accepted. 4ms
aQuaYi Jun 5, 2019
b3ec829
1003 done
aQuaYi Jun 5, 2019
0a2640c
更新 README.md
aQuaYi Jun 5, 2019
0bb6f48
1003 add test case
aQuaYi Jun 6, 2019
f422c4d
1004 added
aQuaYi Jun 6, 2019
95c03b2
1004 准备换个思路
aQuaYi Jun 6, 2019
78f9d9b
1004 doing
aQuaYi Jun 6, 2019
0220820
1004 accepted. 56ms.
aQuaYi Jun 6, 2019
6a23cd8
1004 done
aQuaYi Jun 6, 2019
dc19a76
更新 README.md
aQuaYi Jun 6, 2019
338968e
implementation using the container/list library
kakugirai Jun 6, 2019
62ee99b
1006 done
aQuaYi Jun 7, 2019
0409b04
1007 added
aQuaYi Jun 7, 2019
4219ce3
1007 accepted. 128ms, faster than 46.85%
aQuaYi Jun 7, 2019
00823cc
1008 added
aQuaYi Jun 7, 2019
ce8ddbf
1008 accepted.
aQuaYi Jun 7, 2019
af8d7da
1008 finish
aQuaYi Jun 7, 2019
96f7e44
更新 README.md
aQuaYi Jun 7, 2019
ef8ece7
1011 added
aQuaYi Jun 8, 2019
bb1e1ab
1011 accepted. 48ms, faster than 25%.
aQuaYi Jun 8, 2019
a7a53e8
1011 accepted. 36ms
aQuaYi Jun 8, 2019
42673b1
1011 done
aQuaYi Jun 8, 2019
3b1f06e
更新 README.md
aQuaYi Jun 8, 2019
19cacdd
1007 !00% coverage
aQuaYi Jun 8, 2019
17e0216
1012 added
aQuaYi Jun 9, 2019
2c448f2
1012 finish
aQuaYi Jun 9, 2019
b581f19
更新 README.md
aQuaYi Jun 9, 2019
b38d327
Merge pull request #42 from kakugirai/lru-cache-patch
aQuaYi Jun 9, 2019
74f9f0e
1014 added
aQuaYi Jun 10, 2019
4d800e5
1014 accepted. 52ms
aQuaYi Jun 10, 2019
094436b
1014 done
aQuaYi Jun 10, 2019
cc776dd
更新 README.md
aQuaYi Jun 10, 2019
64b7791
1015 prepared
aQuaYi Jun 11, 2019
aadd648
1015 wrong answer
aQuaYi Jun 11, 2019
1721060
1015 accepted. 40ms, faster than 9.68%
aQuaYi Jun 11, 2019
9b33aab
更新 README.md
aQuaYi Jun 11, 2019
1fed790
1015 done
aQuaYi Jun 11, 2019
ba28649
1016 prepared
aQuaYi Jun 12, 2019
9b8d541
1016 done
aQuaYi Jun 12, 2019
239de7e
1017 prepared
aQuaYi Jun 12, 2019
9bbc4fe
1017 wrong answer
aQuaYi Jun 12, 2019
4ca88fc
1017 accepted. 0ms
aQuaYi Jun 12, 2019
96eedae
1017 finish
aQuaYi Jun 12, 2019
1078f39
更新 README.md
aQuaYi Jun 12, 2019
987e42f
1018 accepted. 356 ms, faster than 12.74%
aQuaYi Jun 12, 2019
fafb591
1018 done
aQuaYi Jun 12, 2019
de1591e
更新 README.md
aQuaYi Jun 12, 2019
e1e09ff
1019 prepared.
aQuaYi Jun 12, 2019
3230e9b
1019 accepted. 1488 ms, faster than 23.49%
aQuaYi Jun 12, 2019
3ed94a4
1019 accepted.
aQuaYi Jun 12, 2019
eeb13a9
更新 README.md
aQuaYi Jun 12, 2019
bda9fa8
1020 prepared
aQuaYi Jun 13, 2019
79a3324
1020 done
aQuaYi Jun 13, 2019
61bf370
1023 prepared
aQuaYi Jun 13, 2019
8088d4f
1023 错误地理解了题意
aQuaYi Jun 13, 2019
7e6b326
1023 accepted.
aQuaYi Jun 13, 2019
4baed55
1023 done
aQuaYi Jun 13, 2019
2157acd
更新 README.md
aQuaYi Jun 13, 2019
e3321f0
更新 Travis-CI 的 go 版本到 1.12
aQuaYi Jun 14, 2019
c2c0693
1024 prepared
aQuaYi Jun 14, 2019
b354f6d
1024 wrong answer
aQuaYi Jun 14, 2019
9c4cf4c
Merge branch 'develop' of https://github.com/aQuaYi/LeetCode-in-Go in…
aQuaYi Jun 14, 2019
d4ff09b
1024 done
aQuaYi Jun 14, 2019
aae43f1
更新 README.md
aQuaYi Jun 14, 2019
1493c9a
1026 prepared
aQuaYi Jun 15, 2019
d814ad4
1026 accepted. 0ms
aQuaYi Jun 15, 2019
8f92964
1026 done
aQuaYi Jun 15, 2019
d3d459c
更新 README.md
aQuaYi Jun 15, 2019
764d239
1026 done
aQuaYi Jun 15, 2019
d7d3a7e
1027 Limit Time Exceeded
aQuaYi Jun 16, 2019
d9fc4a8
1027 accepted. 648ms
aQuaYi Jun 16, 2019
45fe1b8
1027 复制了最快的代码
aQuaYi Jun 16, 2019
b7610e9
1027 整理好了
aQuaYi Jun 16, 2019
09f6d01
1027 done
aQuaYi Jun 16, 2019
e7cfa0b
1027 done
aQuaYi Jun 16, 2019
fd8aec8
更新 README.md
aQuaYi Jun 16, 2019
b0aa9ee
1027 done
aQuaYi Jun 16, 2019
c87c9a4
1028 prepared
aQuaYi Jun 17, 2019
2b057f1
1028 index out of range
aQuaYi Jun 17, 2019
1fc7135
1028 accepted. 12ms, faster than 98.88%
aQuaYi Jun 17, 2019
cd2ccde
1028 done
aQuaYi Jun 17, 2019
7c5cf0f
更新 README.md
aQuaYi Jun 17, 2019
bac1620
1031 prepared
aQuaYi Jun 18, 2019
7ddc47c
1031 accepted. 4ms, faster than 60.71%
aQuaYi Jun 18, 2019
406faca
1031 add test case
aQuaYi Jun 18, 2019
5d339b6
1031 done
aQuaYi Jun 18, 2019
fdb7fe0
更新 README.md
aQuaYi Jun 18, 2019
c4e2546
1034 没有完全理解题意
aQuaYi Jun 19, 2019
bfaec3b
1034 accepted. 20 ms, faster than 97.78%
aQuaYi Jun 19, 2019
162a1a3
1034 done
aQuaYi Jun 19, 2019
919357d
更新 README.md
aQuaYi Jun 19, 2019
230b0c8
1032 低估了题目的意思
aQuaYi Jun 20, 2019
3342252
1032 错误理解了题意
aQuaYi Jun 20, 2019
421b38c
1032 低估了题目的难度
aQuaYi Jun 20, 2019
ba36a79
1032 继续解决中
aQuaYi Jun 20, 2019
cc666df
1032 accepted, 328 ms, faster than 60.38%
aQuaYi Jun 20, 2019
a358135
1032 accepted. 288ms , new record
aQuaYi Jun 21, 2019
773d9b4
1032 done
aQuaYi Jun 21, 2019
2543ca1
1032 done
aQuaYi Jun 21, 2019
d86c8ae
更新 README.md
aQuaYi Jun 21, 2019
f96d363
1035 prepared
aQuaYi Jun 21, 2019
165b45d
1035 accepted. 4ms
aQuaYi Jun 21, 2019
db8531e
更新 README.md
aQuaYi Jun 21, 2019
db30364
1036 prepared.
aQuaYi Jun 22, 2019
4b8a34a
1036 doing
aQuaYi Jun 22, 2019
4f2798f
1036 accepted. 152 ms, faster than 79.17%
aQuaYi Jun 22, 2019
568db98
1036 done
aQuaYi Jun 22, 2019
4b04e00
更新 README.md
aQuaYi Jun 22, 2019
307e2d2
1036 add commit
aQuaYi Jun 22, 2019
ecc2320
1036 delete cutOff variable
aQuaYi Jun 22, 2019
68b7263
1036 add test case
aQuaYi Jun 22, 2019
b240709
travis just master version
aQuaYi Jun 22, 2019
789fd8d
helper 以后 TreeNode 可以直接导入了
aQuaYi Jun 23, 2019
409f7f8
1038 done
aQuaYi Jun 23, 2019
ffe4274
1039 added
aQuaYi Jun 23, 2019
33760ce
1039 错误的解法
aQuaYi Jun 23, 2019
f7be094
1039 开始尝试动态规划解法
aQuaYi Jun 23, 2019
02682f1
1039 错误的答案
aQuaYi Jun 23, 2019
adf3bd1
1039 done
aQuaYi Jun 23, 2019
469fbe5
更新 README.md
aQuaYi Jun 23, 2019
11e8f63
Merge branch 'develop'
aQuaYi Jun 23, 2019
90f1cc6
1040 无法求出最小步骤
aQuaYi Jun 24, 2019
22518b2
1040 done
aQuaYi Jun 24, 2019
2d0080a
1040 done
aQuaYi Jun 24, 2019
0059c7e
更新 README.md
aQuaYi Jun 24, 2019
9a2e171
1043 prepared
aQuaYi Jun 25, 2019
112ccc1
1043 wrong answer
aQuaYi Jun 25, 2019
716b785
1043 copy 了答案
aQuaYi Jun 25, 2019
e9b161f
1043 done
aQuaYi Jun 25, 2019
3114396
更新 README.md
aQuaYi Jun 25, 2019
39b8f07
1043 fix buggy
aQuaYi Jun 25, 2019
2a44ce1
1022 accepted.
aQuaYi Jun 26, 2019
90abc1b
1022 done
aQuaYi Jun 26, 2019
6ffd2c7
1025 accepted.
aQuaYi Jun 26, 2019
0a8884f
1025 done
aQuaYi Jun 26, 2019
f35a284
更新 README.md
aQuaYi Jun 26, 2019
31c4ace
1029 wrong answer
aQuaYi Jun 26, 2019
7dfe455
更新 README.md
aQuaYi Jun 26, 2019
7279acc
1030 accepted. 656ms
aQuaYi Jun 27, 2019
bf9c770
1030 accepted. 528ms
aQuaYi Jun 27, 2019
135d9fa
1030 copy the fastest answer
aQuaYi Jun 27, 2019
71674f6
1030 accepted. 并没有变快
aQuaYi Jun 27, 2019
f55245b
1030 accepted.
aQuaYi Jun 27, 2019
37768f1
更新 README.md
aQuaYi Jun 27, 2019
c347b11
1030 添加了 abs 的 benchmark
aQuaYi Jun 27, 2019
c7e7d8d
1030 修改了 benchmark 的名称
aQuaYi Jun 27, 2019
d286040
1030 more clean
aQuaYi Jun 28, 2019
cf0dd64
1033 wrong answer
aQuaYi Jun 28, 2019
147cfe8
1033 done
aQuaYi Jun 28, 2019
d723bc4
更新 README.md
aQuaYi Jun 28, 2019
a999c3a
1037 prepared
aQuaYi Jun 29, 2019
577a6d4
1037 accepted.
aQuaYi Jun 29, 2019
70f154f
1037 done
aQuaYi Jun 29, 2019
ceef013
更新 README.md
aQuaYi Jun 29, 2019
c31cb41
选取了修改
aQuaYi Jun 29, 2019
d8ccff0
更新 README.md
aQuaYi Jun 29, 2019
88b6037
1041 wrong answer
aQuaYi Jun 30, 2019
2cabaee
1041 wrong answer
aQuaYi Jun 30, 2019
7e08eb6
1041 wrong answer
aQuaYi Jun 30, 2019
36d01d3
1041 accepted.
aQuaYi Jun 30, 2019
a0f20ef
更新 README.md
aQuaYi Jun 30, 2019
8043950
1042 added
aQuaYi Jul 1, 2019
644f2d6
1042 wrong answer
aQuaYi Jul 1, 2019
67fa522
1042 accepted. 180ms
aQuaYi Jul 1, 2019
9dca6ed
1042 done
aQuaYi Jul 1, 2019
1ff27f7
更新 README.md
aQuaYi Jul 1, 2019
a1c491f
1046 accepted.
aQuaYi Jul 2, 2019
6f1d815
1046 done
aQuaYi Jul 2, 2019
ed254dc
更新 README.md
aQuaYi Jul 2, 2019
ccc68dc
1047 done
aQuaYi Jul 3, 2019
7cf33e2
更新 README.md
aQuaYi Jul 3, 2019
fae4d55
更新 README.md
aQuaYi Jul 3, 2019
2ddfbb6
1048 added
aQuaYi Jul 4, 2019
897a6cf
1048 wrong answer
aQuaYi Jul 4, 2019
f8a016a
1048 accepted. 16ms
aQuaYi Jul 4, 2019
2329941
1048 done
aQuaYi Jul 4, 2019
e40c77c
更新 README.md
aQuaYi Jul 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 与题解有关的 issue 模板

## 题号

## 我的疑问

-------

有偿答疑,[点击后,扫码付费](https://github.com/aQuaYi/LeetCode-in-Go/blob/master/.github/pay.png)
Binary file added .github/pay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/
*.cookie
.vscode/
*.toml
helper
helper
*.zip
tasks.txt
testDir/
coverage.txt

# 删除 Goland 设置
.idea

.orig
13 changes: 5 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
language: go

go:
- 1.9.x
- master

# whitelist
branches:
only:
- master
- stable
- stable

script:
script:
- go get -t -v ./...
- go vet ./...
- bash ./test.sh

after_success:
- bash <(curl -s https://codecov.io/bash)

notifications:
webhooks: https://hooks.pubu.im/services/3wp9q4yqlzm8fxr
- bash <(curl -s https://codecov.io/bash)
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "debug",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${fileDirname}"
}
]
}
177 changes: 177 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"todo-tree.flat": true,
"cSpell.words": [
"ASCI",
"GGLLGG",
"GLGLGGLGL",
"GLRLLGLL",
"Gawl",
"Gawlme",
"Gawlqt",
"Gawluvn",
"Gaxwul",
"Gcamwel",
"Gnaynwl",
"IDID",
"Icode",
"Inorder",
"Leet",
"Puerkito",
"Qedo",
"Satisfiability",
"Squareful",
"Subarrays",
"Subsequences",
"Superstring",
"a",
"aaleex",
"abcdefgb",
"abcdefgbabcdei",
"abcdefgh",
"abcdefghijklmnopqrstuvwxyz",
"alexlovesleetcode",
"alicez",
"append",
"arith",
"asdfdfs",
"assqjfwarvjcjedqtoz",
"at",
"atgcatc",
"b",
"bbazb",
"bcdei",
"bool",
"boustrophedonically",
"byte",
"cancel",
"cands",
"capitlization",
"catg",
"cedefifgstkyxfcuajfa",
"checked",
"chromedp",
"clean",
"codecov",
"count",
"ctaagt",
"ctxt",
"cut",
"czvh",
"deck",
"dfs",
"diff",
"domain",
"dot",
"dqtozctcdk",
"e",
"efghabcd",
"emails",
"enention",
"exection",
"exention",
"fassqjfwarvjcjedq",
"fcuajfassqjfwarvjc",
"fgbabcde",
"for",
"fumcfsngphjyfhhwkqa",
"func",
"fwarvjcjedqtozctcd",
"gcta",
"gctaagttcatgcatc",
"ghefcdab",
"gitignore",
"goconvey",
"gruj",
"grukj",
"grukkmj",
"grukmj",
"hgfedcba",
"i",
"if",
"increasing",
"index",
"indexs",
"inention",
"int",
"ints",
"is",
"j",
"keet",
"keti",
"keto",
"ksqsq",
"ksqvsq",
"ksqvsyq",
"kssq",
"kyxfcuajfassqjfwa",
"laiden",
"leelee",
"leetcode",
"len",
"length",
"lexicographicaly",
"lleeelee",
"longest",
"make",
"map",
"max",
"mozillazg",
"n",
"nbsp",
"next",
"ntse",
"num",
"nums",
"ooncedefifgstkyxfcua",
"ppedxfumcfsngphjyf",
"pwwkew",
"querys",
"rame",
"range",
"replace",
"res",
"return",
"revealed",
"rorse",
"saeed",
"seq",
"size",
"sort",
"split",
"ssaaedd",
"stretchr",
"string",
"strings",
"strs",
"subarray",
"subtrees",
"superpalindrome",
"superpalindromes",
"t",
"tail",
"tcode",
"testemail",
"tmps",
"true",
"ttca",
"unique",
"univalued",
"username",
"uvwxyz",
"var",
"wordlist",
"worldabcefghijkmnpqstuvxyz",
"yeellow",
"yllw",
"yollew",
"yollow",
"zcpzvh",
"zczpzfvdhx",
"zczpzvdhx",
"zczpzvh",
"zczpzvhx",
"zczvh",
"zppedxfumcfsngp"
],
"cSpell.language": "en,en-US"
}
6 changes: 6 additions & 0 deletions .vscode/tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.9~svn20110310 //
16 changes: 10 additions & 6 deletions Algorithms/0001.two-sum/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# [1. Two Sum](https://leetcode.com/problems/two-sum/)

## 题目

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

Example:
```

```text
Given nums = [2, 7, 11, 15], target = 9,

Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
```

## 解题思路
```

```go
a + b = target
```

也可以看成是
```

```go
a = target - b
```

在`map[整数]整数的序号`中,可以查询到a的序号。这样就不用嵌套两个for循环了。


在`map[整数]整数的序号`中,可以查询到a的序号。这样就不用嵌套两个for循环了。
16 changes: 8 additions & 8 deletions Algorithms/0001.two-sum/two-sum.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package Problem0001
package problem0001

func twoSum(nums []int, target int) []int {
// m 负责保存map[整数]整数的序列号
m := make(map[int]int, len(nums))
// index 负责保存map[整数]整数的序列号
index := make(map[int]int, len(nums))

// 通过 for 循环,获取b的序列号
for i, b := range nums {
// 通过查询map,获取a = target - b的序列号
if j, ok := m[target-b]; ok {
if j, ok := index[target-b]; ok {
// ok 为 true
// 说明在i之前,存在nums[j] == a
// 说明在i之前,存在 nums[j] == a
return []int{j, i}
// 注意,顺序是j,i,因为j<i
// 注意,顺序是j,i
}

// 把i和i的值,存入map
m[nums[i]] = i
// 把b和i的值,存入map
index[b] = i
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion Algorithms/0001.two-sum/two-sum_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Problem0001
package problem0001

import (
"testing"
Expand Down
8 changes: 8 additions & 0 deletions Algorithms/0002.add-two-numbers/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
# [2. Add Two Numbers](https://leetcode.com/problems/add-two-numbers/)

## 题目

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

```text
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
```

## 解题思路

```text
(2 -> 4 -> 3)是 342

(5 -> 6 -> 4)是 465

(7 -> 0 -> 8)是 807

342 + 465 = 807
```

所以,题目的本意是,把整数换了一种表达方式后,实现其加法。

设计程序时候,需要处理的点有

1. 位上的加法,需要处理进位问题
1. 如何进入下一位运算
1. 按位相加结束后,也还需要处理进位问题。

## 总结

读懂题意后,按步骤实现题目要求。
Loading