655. Print Binary Tree 解题报告(树)

摘要: 第一部分:搜索、遍历 【例子1】655. Print Binary Tree Example 1: Example 2: 思路:先求高度,初始化数组,然后DFS递归即可。在DFS时,需要注意确定左右边界。 代码: vector<vector<string>> printTree(TreeNode* 阅读全文
posted @ 2017-08-13 12:54 1592653 阅读(956) 评论(0) 推荐(0) 编辑

445. Add Two Numbers II 题解报告(链表)

摘要: ListNode* reverseKGroup(ListNode* head, int k) { // if(!head||k==1)return head; int cnt=0; ListNode* p = head, *newh = new ListNode(0), *pre = newh; w 阅读全文
posted @ 2017-08-09 13:16 1592653 阅读(193) 评论(0) 推荐(0) 编辑

LeetCode 582. Kill Process 解题报告(队列)

摘要: 【例子1】 Kill Process Problem statement: Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each process onl 阅读全文
posted @ 2017-08-08 11:43 1592653 阅读(529) 评论(0) 推荐(0) 编辑

leetcode 456. 132 Pattern 132模式 题解(栈)

摘要: 【例子1】132 Pattern https://leetcode.com/problems/132-pattern/description/ Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence 阅读全文
posted @ 2017-08-06 23:24 1592653 阅读(852) 评论(0) 推荐(0) 编辑