Go
烧饼夹凉粉
这个作者很懒,什么都没留下…
展开
-
Go问题
Go struct能不能比较 答案:能也不能,具体情况具体分析 首先要明确的是Go中map、slice、func都不能比较 所以对于相同struct的不同实例,如果struct中有map、slice、func的话无法比较,无法编译。 type t1 struct { m int n int s []int } type t2 struct { m int n int } func main() { x := t1{m: 0, n: 0} y := t1{m: 0, n: 1}原创 2021-04-01 19:11:02 · 119 阅读 · 0 评论 -
LC435
LC.435无重叠区间 这题第二次写了,有思路但还是写反了,特此记录提醒。 type in [][]int func (p in) Len() int { return len(p) } func (p in) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p in) Less(i, j int) bool { return p[i][1] < p[j][1] } func eraseOverlapIntervals(intervals原创 2021-04-01 00:18:22 · 80 阅读 · 0 评论 -
Golang——函数
函数 在go中,函数也是值。它们可以像其它值一样传递。 函数值可以用作函数的参数或返回值。 意味着我们可以在一个函数中声明并使用一个新的函数: func main() { hypot := func(x, y float64) float64 { return math.Sqrt(x*x + y*y) } fmt.Println(hypot(5, 12)) } 也可以先声明函数类型的变量,无名参数列表,然后定义。 func main() { var hypot func(float64, fl原创 2021-03-31 14:13:08 · 102 阅读 · 0 评论 -
2021-03-31
Go踩的坑 今天在用go做一道回溯算法题 func subsetsWithDup(nums []int) [][]int { sort.Ints(nums) var res [][]int = make([][]int, 0) path := make([]int, 0) var dfs func(bool, int) dfs = func(preNum bool, pos int) { if pos == len(nums) { //fmt.Println(path) /原创 2021-03-31 13:55:27 · 87 阅读 · 0 评论