FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

103 - 第四周作业 by yush-jiang · Pull Request #720 · algorithm001/algorithm · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .go  (3) .md  (1) .xml  (1) dotfile  (1) All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
213 changes: 213 additions & 0 deletions Week_02/id_103/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Week_04/id_103/.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

.idea
6 changes: 5 additions & 1 deletion Week_04/id_103/NOTE.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# 学习笔记
# 学习笔记

- 169 既然一个数半数都存在,那排好序之后,一定在中间
- 455 这个排序后,看每块饼干能否满足小朋友,能的话,就递增,不能就再继续,就能判断出来了,不过对小朋友的胃口和饼干要提前排序。
- 746 到达当前台阶时判断下从前一个台阶过来省事,还是从前一个的前一个过来省事,一直累加到最后一个台阶完,最小值就是最省体力的。 用p1和p2表示前两个和前一个台阶所耗费的体力,一遍循环就可以了。
8 changes: 8 additions & 0 deletions Week_04/id_103/leetcode_103_169.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package id_103

import "sort"

func majorityElement(nums []int) int {
sort.Ints(nums)
return nums[len(nums) / 2]
}
16 changes: 16 additions & 0 deletions Week_04/id_103/leetcode_103_455.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package id_103

import "sort"

func findContentChildren(g []int, s []int) int {
sort.Ints(g)
sort.Ints(s)
child, cookie := 0,0
for child < len(g) && cookie < len(s){
if g[child] <= s[cookie]{
child++
}
cookie++
}
return child
}
17 changes: 17 additions & 0 deletions Week_04/id_103/leetcode_103_746.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package id_103

func minCostClimbingStairs(cost []int) int {
p1,p2 := 0,0
for i := 2; i <= len(cost); i++ {
p1 , p2 = p2, min(p2 + cost[i-1],p1+cost[i-2])
}
return p2
}

func min(a,b int) int {
if a > b{
return b
}else{
return a
}
}

Back | FazBrowse Home | New Git URL