文章分类 - LeetCode
摘要:/*one can sell and buy at the same daygreedy algorithm: just find the increase subsequence*/class Solution {public: int maxProfit(vector &prices) {...
阅读全文
摘要:class Solution {public: int maxProfit(vector &prices) { int size = prices.size(); if( size==0 || size==1) return 0; ...
阅读全文
摘要:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(...
阅读全文
摘要:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(...
阅读全文
摘要:层遍历,二叉树高度
阅读全文
摘要:struct TreeNode{ int val; TreeNode *left; TreeNode *right; TreeNode(int x):val(x),left(NULL),right(NULL){};};class Solution{public: vectorinorderTrave...
阅读全文
摘要:class Solution{public: vectorpreorderTraversal(TreeNode *root) { vectorpreOrder; Traversal(root,preOrder); return preOrder; } stack st;private: voi...
阅读全文
摘要:1 class Solution{ 2 public: 3 vectorpostorderTraversal(TreeNode *root) 4 { 5 vectorpostOrder; 6 Traversal(root,postOrder); 7 ...
阅读全文