摘要: 参考 https://blog.csdn.net/wonner_/article/details/80373871 回溯算法的定义:回溯算法也叫试探法,它是一种系统地搜索问题的解的方法。回溯算法的基本思想是:从一条路往前走,能进则进,不能进则退回来,换一条路再试。 回溯算法实际上一个类似枚举的搜索尝 阅读全文
posted @ 2018-11-08 16:32 KeepAC 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 104. Maximum Depth of Binary Tree 求二叉树最大深度 return its depth = 3. 559. Maximum Depth of N-ary Tree 一开始写成这样, 结果怎么都不对: 因为 这里 maxDepth(child) 根本不会 hit roo 阅读全文
posted @ 2018-11-08 13:07 KeepAC 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 105. Construct Binary Tree from Preorder and Inorder Traversal https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal 阅读全文
posted @ 2018-11-06 15:16 KeepAC 阅读(112) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/binary-tree-pruning/description/ 一颗树中有0和1的节点,要求删除所有可以被删除的0节点,直接看下图就明白了。 分析: 如果是叶子节点为0,那直接删除, 删除后 如果新的叶子节点 也是0 继续删除。。。 一开 阅读全文
posted @ 2018-11-06 15:06 KeepAC 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 241. https://leetcode.com/problems/different-ways-to-add-parentheses/description/ 282. https://leetcode.com/problems/expression-add-operators/descript 阅读全文
posted @ 2018-11-06 04:58 KeepAC 阅读(78) 评论(0) 推荐(0) 编辑
摘要: 1. https://leetcode.com/problems/basic-calculator/description/ 2. https://leetcode.com/problems/basic-calculator-ii/description/ 3. https://leetcode.c 阅读全文
posted @ 2018-11-06 04:01 KeepAC 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 20. https://leetcode.com/problems/valid-parentheses/description/ 678. https://leetcode.com/problems/valid-parenthesis-string/description/ 32. https:// 阅读全文
posted @ 2018-11-04 01:20 KeepAC 阅读(160) 评论(0) 推荐(0) 编辑
摘要: leetcode 20 :https://leetcode.com/problems/valid-parentheses/description/ 如果 stack 为空时,pop()会 抛出exception, 处理的方法如下: 阅读全文
posted @ 2018-11-03 03:50 KeepAC 阅读(301) 评论(0) 推荐(0) 编辑
摘要: 1. 297: https://leetcode.com/articles/serialize-and-deserialize-binary-tree/ 2. 449: https://leetcode.com/problems/serialize-and-deserialize-bst/descr 阅读全文
posted @ 2018-10-31 03:56 KeepAC 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 769 题意: 一个数组是 0-N-1 的组合, 数组可以被分成多个chunks, 主要chunks 内部排序好了,整个数组就可以排序好。 768:题目: 和768 类似,只是数组是任意的,不是0-N-1的组合。 比较两个子数组 是否一样arr1: [1 2 1 2]arr2: [2 2 1 1] 阅读全文
posted @ 2018-10-28 13:23 KeepAC 阅读(93) 评论(0) 推荐(0) 编辑