2013年4月30日
摘要: 1 class Solution { 2 public: 3 int lengthOfLastWord(const char *s) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 const char *p,*q; 7 p=s; 8 q=p+strlen(p)-1; 9 10 while(p<q)11 {12 ... 阅读全文
posted @ 2013-04-30 22:45 宇睿 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 bool isInterleave(string s1, string s2, string s3) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 if(s1.size()==0&&s2.size()==0&&s3.size()==0) 7 return true; 8 if(s1.size()+s2.siz... 阅读全文
posted @ 2013-04-30 22:22 宇睿 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int threeSumClosest(vector<int> &num, int target) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 int i,j,k; 7 int r; 8 int len=num.size(); 9 r=INT_MAX/10;10 for(i=0;i<le... 阅读全文
posted @ 2013-04-30 17:36 宇睿 阅读(122) 评论(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 isSameTree(TreeNode *p, TreeNode *q) {13 // S... 阅读全文
posted @ 2013-04-30 17:18 宇睿 阅读(118) 评论(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> > pathSum(TreeNode *root, int sum) {13 ... 阅读全文
posted @ 2013-04-30 17:07 宇睿 阅读(129) 评论(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 hasPathSum(TreeNode *root, int sum) {13 // St... 阅读全文
posted @ 2013-04-30 16:30 宇睿 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 vector<int> plusOne(vector<int> &digits) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 int c=0; 7 int i=digits.size()-1; 8 vector<int> v; 9 int t=digits[i];10 digits[i... 阅读全文
posted @ 2013-04-30 16:19 宇睿 阅读(155) 评论(0) 推荐(0) 编辑