2013年6月3日
摘要: // 56ms 1 class Solution { 2 public: 3 4 void DFS(vector<vector<char>> &v,int i,int j) 5 { 6 if(v[i][j]=='O') 7 { 8 v[i][j]='Q'; 9 if(i>0)10 DFS(v,i-1,j);11 if(i<v.size()-1)12 DFS(v,i+1,j);13 ... 阅读全文
posted @ 2013-06-03 10:47 宇睿 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for an interval. 3 * struct Interval { 4 * int start; 5 * int end; 6 * Interval() : start(0), end(0) {} 7 * Interval(int s, int e) : start(s), end(e) {} 8 * }; 9 */10 class Solution;11 bool incmp(struct Interval a,struct Interval b)12 {13 ... 阅读全文
posted @ 2013-06-03 10:31 宇睿 阅读(152) 评论(0) 推荐(0) 编辑
摘要: //风格比较差,用时较长:712ms 1 /** 2 * Definition for an interval. 3 * struct Interval { 4 * int start; 5 * int end; 6 * Interval() : start(0), end(0) {} 7 * Interval(int s, int e) : start(s), end(e) {} 8 * }; 9 */10 class Solution;11 bool incmp(struct Interval a,struct Interval b)... 阅读全文
posted @ 2013-06-03 10:23 宇睿 阅读(175) 评论(0) 推荐(0) 编辑
摘要: //这个方案目前超时,需要其他方法 1 char vf[100][100]; 2 3 class Solution { 4 public: 5 6 7 bool DFS(vector<vector<char> > &v,int i,int j,const char *p) 8 { 9 bool r; 10 11 12 if(v[i][j]!=p[0]) 13 return false; 14 if((v[i][j]==p[0])&&(p[1]... 阅读全文
posted @ 2013-06-03 00:52 宇睿 阅读(145) 评论(0) 推荐(0) 编辑
  2013年6月2日
摘要: 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 11 12 void dep(TreeNode *root,int *d,int t)13 {14 if(root==NULL)15 {16 if(... 阅读全文
posted @ 2013-06-02 22:44 宇睿 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int minimumTotal(vector<vector<int> > &triangle) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 int i; 7 int j; 8 int t1; 9 int t2;10 for(i=triangle.size()-2;i>=0;i--)11... 阅读全文
posted @ 2013-06-02 21:28 宇睿 阅读(144) 评论(0) 推荐(0) 编辑
  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) 编辑