摘要: 二叉树DFS遍历有三种:pre-order, in-order, post-order。遍历的方法有recursion和iteration两种。 1. pre-order前序遍历 递归:这三种遍历的递归做法都非常简单。 非递归:主要是用stack来做。这种更好! 为什么用非递归更好? 如果用递归,我 阅读全文
posted @ 2018-03-31 07:54 机智的小八 阅读(996) 评论(0) 推荐(0) 编辑
摘要: 1. Bipartite: Determine if an undirected graph is bipartite. A bipartite graph is one in which the nodes can be divided into two groups such that no n 阅读全文
posted @ 2018-03-29 07:50 机智的小八 阅读(783) 评论(0) 推荐(0) 编辑
摘要: 1. 用2个stack sort numbers 给定一个stack1,里面的数是unsorted,只允许用额外一个stack2去sort这个stack。 分析思路如下: 一个global_min来放当前最小值(初始为stack1.pop()出来的值) 然后依次和stack1.pop()出来的值进行 阅读全文
posted @ 2018-03-19 01:26 机智的小八 阅读(643) 评论(0) 推荐(0) 编辑
摘要: 一 Recursion 1. base case: smallest problem 2. subproblem 3. recursion rule fibonacci 数列 fibo(n)=fibo(n-1)+fibo(n-2) 如果单纯用递归来写,分析如下: base case:n=1 retu 阅读全文
posted @ 2018-03-15 10:03 机智的小八 阅读(342) 评论(0) 推荐(0) 编辑
摘要: 总结两道题,都是和数组有关。 Spiral Matrix(LC54 Medium): Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Fo 阅读全文
posted @ 2017-12-10 12:09 机智的小八 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 持续更新。。。 github链接:https://github.com/x2mercy/Leetcode_Solution 今天第一次遇到贪心算法。 基本思路来自百度百科 贪心算法参考:http://blog.csdn.net/qq_32400847/article/details/51336300 阅读全文
posted @ 2017-12-04 12:55 机智的小八 阅读(1459) 评论(0) 推荐(0) 编辑
摘要: 原理和c++实现:https://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matching.html 目的是检测、定位一个物体在一副图像中的位置,主要是通过计算两幅图(待检测图像和 阅读全文
posted @ 2017-11-20 11:01 机智的小八 阅读(6797) 评论(1) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2017-11-18 10:09 机智的小八 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 今天做到一个题目: 17. Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations that the number could represent. A m 阅读全文
posted @ 2017-11-15 11:40 机智的小八 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 1. 二叉树遍历:http://blog.csdn.net/bone_ace/article/details/46718683 2. 搜索树和BST:http://blog.csdn.net/qq_21688757/article/details/53843724 3. deque:http://b 阅读全文
posted @ 2017-11-15 07:42 机智的小八 阅读(208) 评论(0) 推荐(0) 编辑