文章分类 -  LeetCode

摘要:/*one can sell and buy at the same daygreedy algorithm: just find the increase subsequence*/class Solution {public: int maxProfit(vector &prices) {... 阅读全文
posted @ 2014-11-25 10:22 dupuleng 阅读(83) 评论(0) 推荐(0) 编辑
摘要:class Solution {public: int maxProfit(vector &prices) { int size = prices.size(); if( size==0 || size==1) return 0; ... 阅读全文
posted @ 2014-11-25 10:21 dupuleng 阅读(79) 评论(0) 推荐(0) 编辑
摘要:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(... 阅读全文
posted @ 2014-07-01 20:06 dupuleng 阅读(84) 评论(0) 推荐(0) 编辑
摘要:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(... 阅读全文
posted @ 2014-07-01 18:12 dupuleng 阅读(83) 评论(0) 推荐(0) 编辑
摘要:层遍历,二叉树高度 阅读全文
posted @ 2014-07-01 16:31 dupuleng 阅读(108) 评论(0) 推荐(0) 编辑
摘要:struct TreeNode{ int val; TreeNode *left; TreeNode *right; TreeNode(int x):val(x),left(NULL),right(NULL){};};class Solution{public: vectorinorderTrave... 阅读全文
posted @ 2014-07-01 13:33 dupuleng 阅读(61) 评论(0) 推荐(0) 编辑
摘要:class Solution{public: vectorpreorderTraversal(TreeNode *root) { vectorpreOrder; Traversal(root,preOrder); return preOrder; } stack st;private: voi... 阅读全文
posted @ 2014-07-01 13:29 dupuleng 阅读(76) 评论(0) 推荐(0) 编辑
摘要:1 class Solution{ 2 public: 3 vectorpostorderTraversal(TreeNode *root) 4 { 5 vectorpostOrder; 6 Traversal(root,postOrder); 7 ... 阅读全文
posted @ 2014-07-01 13:16 dupuleng 阅读(100) 评论(0) 推荐(0) 编辑