摘要: class Solution {public: bool isMatch(const char *s, const char *p) { assert(s && p); if(*p=='\0') return *s == '\0'; if (*(p+1)!='*') { assert(*p != '*'); return ((*p == *s) || (*p == '.' && *s != '\0')) && isMatch(s+1, p+1); } 阅读全文
posted @ 2013-06-13 19:22 代码改变未来 阅读(481) 评论(0) 推荐(0) 编辑
摘要: 1.Count and Sayclass Solution {public: string countAndSay(int n) { string s1,s2=""; s1="1"; if(n==1)return s1; for(int i=1;i<n;i++) { int j=0;int k=0; while(j<s1.size()) { char c=s1[j]; while(s1[... 阅读全文
posted @ 2013-06-13 15:37 代码改变未来 阅读(124) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int[][] generateMatrix(int n) { // Start typing your Java solution below // DO NOT write main() function int [][] matrix =new int[n][n]; int start=0, end=n-1; int num=1; while(start<end) { for(int j=start;j<end;j++) { ma... 阅读全文
posted @ 2013-06-13 00:23 代码改变未来 阅读(1562) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int reverse(int x) { int y=abs(x); int z=0; while(y>0) { z=z*10+y%10; y=y/10; } if(x>0)return z; if(x<0)return -z; }}; 阅读全文
posted @ 2013-06-13 00:09 代码改变未来 阅读(121) 评论(0) 推荐(0) 编辑