| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + # Binaries for programs and plugins | ||
| 2 | + *.exe | ||
| 3 | + *.exe~ | ||
| 4 | + *.dll | ||
| 5 | + *.so | ||
| 6 | + *.dylib | ||
| 7 | + | ||
| 8 | + # Test binary, build with `go test -c` | ||
| 9 | + *.test | ||
| 10 | + | ||
| 11 | + # Output of the go coverage tool, specifically when used with LiteIDE | ||
| 12 | + *.out | ||
| 13 | + | ||
| 14 | + .idea | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1 +1,5 @@ | |||
| 1 | - # 学习笔记 | ||
| 1 | + # 学习笔记 | ||
| 2 | + | ||
| 3 | + - 169 既然一个数半数都存在,那排好序之后,一定在中间 | ||
| 4 | + - 455 这个排序后,看每块饼干能否满足小朋友,能的话,就递增,不能就再继续,就能判断出来了,不过对小朋友的胃口和饼干要提前排序。 | ||
| 5 | + - 746 到达当前台阶时判断下从前一个台阶过来省事,还是从前一个的前一个过来省事,一直累加到最后一个台阶完,最小值就是最省体力的。 用p1和p2表示前两个和前一个台阶所耗费的体力,一遍循环就可以了。 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,8 @@ | |||
| 1 | + package id_103 | ||
| 2 | + | ||
| 3 | + import "sort" | ||
| 4 | + | ||
| 5 | + func majorityElement(nums []int) int { | ||
| 6 | + sort.Ints(nums) | ||
| 7 | + return nums[len(nums) / 2] | ||
| 8 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + package id_103 | ||
| 2 | + | ||
| 3 | + import "sort" | ||
| 4 | + | ||
| 5 | + func findContentChildren(g []int, s []int) int { | ||
| 6 | + sort.Ints(g) | ||
| 7 | + sort.Ints(s) | ||
| 8 | + child, cookie := 0,0 | ||
| 9 | + for child < len(g) && cookie < len(s){ | ||
| 10 | + if g[child] <= s[cookie]{ | ||
| 11 | + child++ | ||
| 12 | + } | ||
| 13 | + cookie++ | ||
| 14 | + } | ||
| 15 | + return child | ||
| 16 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,17 @@ | |||
| 1 | + package id_103 | ||
| 2 | + | ||
| 3 | + func minCostClimbingStairs(cost []int) int { | ||
| 4 | + p1,p2 := 0,0 | ||
| 5 | + for i := 2; i <= len(cost); i++ { | ||
| 6 | + p1 , p2 = p2, min(p2 + cost[i-1],p1+cost[i-2]) | ||
| 7 | + } | ||
| 8 | + return p2 | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + func min(a,b int) int { | ||
| 12 | + if a > b{ | ||
| 13 | + return b | ||
| 14 | + }else{ | ||
| 15 | + return a | ||
| 16 | + } | ||
| 17 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments