Skip to content

Commit 067f198

Browse files
committed
rename java
1 parent e871d4a commit 067f198

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+10
-6
lines changed

β€Ž.DS_Store

0 Bytes
Binary file not shown.

β€Ž.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ build/
3434

3535
### log ###
3636
*.log
37-
*.gz
37+
*.gz
38+
39+
.DS_Store
40+
src/.DS_Store
41+
src/main/.DS_Store

β€Žgo/1.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ import "fmt"
88
* 思路1:2ζ¬‘ε“ˆεΈŒζ±‚θ§£οΌšε°†ζ•°η»„ζ”Ύε…₯ζ•£εˆ—θ‘¨οΌŒιεŽ†ζ•£εˆ—θ‘¨οΌŒι€šθΏ‡target-keyεΎ—ε‡ΊεŒΉι…ζ•°η»„οΌŒεΉΆδΈ”εˆ€ζ–­ιžθ‡ͺθΊ«ε…ƒη΄ οΌŒθΏ”ε›žζ•°η»„οΌŒζ—Άι—΄ε€ζ‚εΊ¦ O(nοΌ‰
99
* 思路2[runtime beatsοΌˆζœ€δΌ˜θ§£οΌ‰]:1ζ¬‘ε“ˆεΈŒζ±‚θ§£οΌšεœ¨ιεŽ† num ζ•°η»„οΌŒε¦‚ζžœε“ˆεΈŒθ‘¨δΈεŒ…ε« target - num[i] οΌŒεˆ™ε°† num[i], i ζ”Ύε…₯ε“ˆεΈŒθ‘¨οΌŒε¦‚ζžœεŒ…ε«εˆ™η›΄ζŽ₯θΏ”ε›ž [hash[num[i], i]] δΈ‹ζ ‡
1010
*/
11-
func twoSum(nums []int, target int) []int {
11+
func twoSum(nums []int, target int) []int {
1212
hashMap := map[int]int{}
1313
for i := 0; i < len(nums); i++ {
14-
p, ok := hashMap[target - nums[i]]
14+
p, ok := hashMap[target-nums[i]]
1515
if ok {
1616
return []int{p, i}
1717
}
1818
hashMap[nums[i]] = i
1919
}
2020
return nil
21-
}
21+
}
2222

2323
func main() {
24-
// 声明 slice
24+
// 声明 slice
2525
nums := []int{2, 7, 11, 15}
2626
target := 9
2727
p := twoSum(nums, target)
2828
fmt.Println("p value:", p)
29-
}
29+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
Β (0)