Skip to content

Commit a4985d4

Browse files
committedOct 12, 2018
Update solution 001 [golang][scala]
1 parent 5b7313a commit a4985d4

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed
 

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ I'm looking for long-term contributors/partners to this repo! Send me PRs if you
8686
## Contributors
8787

8888
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
89-
| <center> [<img src="https://avatars3.githubusercontent.com/u/21008209?v=4" width="100px;"/><br /><sub><b>yanglbme</b></sub>](https://github.com/yanglbme)<br />[💻](https://github.com/doocs/leetcode/commits?author=yanglbme "Code") </center> | <center> [<img src="https://avatars3.githubusercontent.com/u/23625436?v=4" width="100px;"/><br /><sub><b>chakyam</b></sub>](https://github.com/chakyam)<br />[💻](https://github.com/doocs/leetcode/commits?author=chakyam "Code") </center> | <center> [<img src="https://avatars3.githubusercontent.com/u/10081554?v=4" width="100px;"/><br /><sub><b>zhkmxx9302013</b></sub>](https://github.com/zhkmxx9302013)<br />[💻](https://github.com/doocs/leetcode/commits?author=zhkmxx9302013 "Code") </center> | <center> [<img src="https://avatars3.githubusercontent.com/u/40383345?v=4" width="100px;"/><br /><sub><b>MarkKuang1991</b></sub>](https://github.com/MarkKuang1991)<br />[💻](https://github.com/doocs/leetcode/commits?author=MarkKuang1991 "Code") </center> |
90-
|---|---|---|--|
89+
| <center> [<img src="https://avatars3.githubusercontent.com/u/21008209?v=4" width="80px;"/>](https://github.com/yanglbme)<br />[💻](https://github.com/doocs/leetcode/commits?author=yanglbme "Code") </center> | <center> [<img src="https://avatars3.githubusercontent.com/u/23625436?v=4" width="80px;"/>](https://github.com/chakyam)<br />[💻](https://github.com/doocs/leetcode/commits?author=chakyam "Code") </center> | <center> [<img src="https://avatars3.githubusercontent.com/u/10081554?v=4" width="80px;"/>](https://github.com/zhkmxx9302013)<br />[💻](https://github.com/doocs/leetcode/commits?author=zhkmxx9302013 "Code") </center> | <center> [<img src="https://avatars3.githubusercontent.com/u/40383345?v=4" width="80px;"/>](https://github.com/MarkKuang1991)<br />[💻](https://github.com/doocs/leetcode/commits?author=MarkKuang1991 "Code") </center> | <center> [<img src="https://avatars3.githubusercontent.com/u/12371194?v=4" width="80px;"/>](https://github.com/fonxian)<br />[💻](https://github.com/doocs/leetcode/commits?author=fonxian "Code") </center> |
90+
|---|---|---|--|--|
9191

9292
<!-- ALL-CONTRIBUTORS-LIST:END -->

‎solution/001.Two Sum/Solution.go

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
package main
2-
31
func twoSum(nums []int, target int) []int {
4-
52
var numsMap map[int]int
63
numsMap = make(map[int]int)
74
for i := 0; i < len(nums); i++ {
@@ -12,5 +9,4 @@ func twoSum(nums []int, target int) []int {
129
numsMap[nums[i]] = i
1310
}
1411
return nil
15-
1612
}

‎solution/001.Two Sum/Solution.scala

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1+
import scala.collection.mutable
12

23
object Solution {
3-
44
def twoSum(nums: Array[Int], target: Int): Array[Int] = {
5-
65
var map = new mutable.HashMap[Int, Int]()
7-
86
for (i <- 0 to nums.length) {
97
if (map.contains(target - nums(i))) {
108
return Array(map(target - nums(i)), i)
@@ -14,5 +12,4 @@ object Solution {
1412
}
1513
Array(0, 0)
1614
}
17-
1815
}

0 commit comments

Comments
 (0)
Please sign in to comment.