- 博客(4)
- 收藏
- 关注
原创 7月8号
剑指 Offer 31. 栈的压入、弹出序列用stack来判断是否需要更新indexfunc validateStackSequences(pushed []int, popped []int) bool { stack := make([]int, 0) index := 0 for _, val := range pushed { stack = append(stack, val) for (len(stack) > 0 &am.
2020-07-08 09:39:20
111
原创 二叉树的后序遍历
145. 二叉树的后序遍历每次访问一个节点之前,先判断该节点的右子树是否被访问,如果没有被访问则先处理右子树。func postorderTraversal(root *TreeNode) []int { res := make([]int, 0) if root == nil { return res } stack := make([]*TreeNode, 0) var lastVisited *TreeNode for root
2020-07-06 09:12:57
135
转载 Go Channels
Go Channels// 单向channelfunc main() { naturals := make(chan int) squares := make(chan int) done := make(chan struct{}) go Counter(naturals) go Squarer(naturals, squares) go Printer(squares, done) <-done}func Counter(naturals chan<- int) {
2020-07-05 23:14:51
66
转载 callback function
A “callback” is any function that is called by another function which takes the first function as a parameter. A lot of the time, a “callback” is a function that is called when something happens. That something can be called an “event” in programmer-speak.
2020-07-05 20:18:17
130
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人