- 博客(13)
- 收藏
- 关注
原创 Leetcode 145. Binary Tree Postorder Traversal
递归/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cl...
2018-03-30 22:38:08 89
原创 Leetcode 144. Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3 return [1,2,3].递归/** * Definition for a binary tree nod...
2018-03-30 20:38:39 76
原创 ***Leetcode 146. LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.get(key) - Get the value (will always be positive) of the key if the ...
2018-03-30 10:56:12 125
原创 用两个栈来实现一个队列
用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。class Solution { public: void push(int node) { stack1.push(node); } int pop() { if (stack1.empty() && stack2.empty()) ret...
2018-03-29 21:57:22 129
原创 重建二叉树
输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。/** * Definition for binary tree * struct TreeNode { * int val; * TreeN
2018-03-28 20:20:25 97
转载 markdown编辑方法
# 欢迎使用Markdown编辑器写博客本Markdown编辑器使用[StackEdit][6]修改而来,用它写博客,将会带来全新的体验哦:- **Markdown和扩展Markdown简洁的语法** - **代码块高亮** - **图片链接和图片上传** - ***LaTex*数学公式** - **UML序列图和流程图** - **离线写博客** - **导入导出Markdown文件** - **
2018-03-28 20:19:08 234 1
原创 错误记录
开发一个简单错误记录功能小模块,能够记录出错的代码所在的文件名称和行号。 处理: 1.记录最多8条错误记录,对相同的错误记录(即文件名称和行号完全匹配)只记录一条,错误计数增加;(文件所在的目录不同,文件名和行号相同也要合并) 2.超过16个字符的文件名称,只记录文件的最后有效16个字符;(如果文件名不同,而只是文件名的后16个字符和行号相同,也不要合并) 3.输入的文件可能带路径,记录...
2018-03-21 15:47:27 128
原创 二维数组中的查找
class Solution { public: bool Find(int target, vector<vector<int> > array) { if (array.size() == 0) return false; if (array[0].size() == 0) return false; vecto...
2018-03-20 11:31:18 126
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人