2013年5月11日
摘要: 1 class Solution { 2 public: 3 double pow(double x, int n) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 if(n==0) 7 return 1; 8 if(x==0) 9 return 0;10 if(x==1)11 return 1;12 ... 阅读全文
posted @ 2013-05-11 20:16 宇睿 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */10 class Solution {11 public:12 bool isM(TreeNode *p,TreeNode *q)13 {14 if((p-... 阅读全文
posted @ 2013-05-11 19:45 宇睿 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */10 class Solution {11 public:12 vector<vector<int> > levelOrder(TreeNode *root) {13 ... 阅读全文
posted @ 2013-05-11 19:44 宇睿 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */10 class Solution {11 public:12 int max=-1;13 void meng(TreeNode*root,int dep)14 ... 阅读全文
posted @ 2013-05-11 19:01 宇睿 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */10 class Solution {11 public:12 vector<vector<int> > levelOrderBottom(TreeNode *root) {13 ... 阅读全文
posted @ 2013-05-11 18:57 宇睿 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */10 class Solution {11 public:12 TreeNode *sortedArrayToBST(vector<int> &num) {13 /... 阅读全文
posted @ 2013-05-11 18:31 宇睿 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */10 class Solution {11 public:12 13 int min=10000;14 void meng(TreeNode*root,int dep)15... 阅读全文
posted @ 2013-05-11 18:15 宇睿 阅读(124) 评论(0) 推荐(0) 编辑
摘要: //这段代码首先判断算法是否正确 :) 1 class Solution { 2 public: 3 bool isP(string s) 4 { 5 string ss; 6 ss.assign(s.rbegin(),s.rend()); 7 if(s==ss) 8 return true; 9 else10 return false;11 }12 int minCut(string s) {13 // Start typin... 阅读全文
posted @ 2013-05-11 14:41 宇睿 阅读(185) 评论(0) 推荐(0) 编辑