摘要:
1 class Solution { 2 public: 3 //计算一个整数的位数,在溢出判断中使用 4 int bit_length(int n) { 5 int l=0; 6 while(n!=0)... 阅读全文
posted @ 2014-10-27 22:22
羽加迪姆勒维奥萨
阅读(203)
评论(0)
推荐(0)
摘要:
1 class Solution {2 public:3 int singleNumber(int A[], int n) {4 int result=A[0];5 for(int i=1;i<n;i++)6 result^=A[i];... 阅读全文
posted @ 2014-10-27 21:53
羽加迪姆勒维奥萨
阅读(158)
评论(0)
推荐(0)
摘要:
1 /* I:1 ; V-5;X-10;L-50;C-100;D-500;M-1000*/ 2 class Solution{ 3 vector tokens; 4 vector token_value; 5 public: 6 /*divide the strin... 阅读全文
posted @ 2014-10-27 21:51
羽加迪姆勒维奥萨
阅读(420)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 public: 4 5 int reverse(int x){ 6 int result=0; 7 while(x!=0) 8 { 9 ... 阅读全文
posted @ 2014-10-27 21:46
羽加迪姆勒维奥萨
阅读(115)
评论(0)
推荐(0)
摘要:
1 bool isPalindrome(int x) { 2 int result=0; 3 //注意下面会修改x的值,所以提前保留 4 int copy_x=x; 5 if(x<0) 6 return... 阅读全文
posted @ 2014-10-27 21:45
羽加迪姆勒维奥萨
阅读(160)
评论(0)
推荐(0)
摘要:
1 class Solution { 2 public: 3 bool isPalindrome(string s) { 4 //清空string内部所有不是字母的内容,要注意的是erase删除后返回其下一个元素,利用这点来连续删除,若使用i++则会导致运行时错误 5 ... 阅读全文
posted @ 2014-10-27 21:44
羽加迪姆勒维奥萨
阅读(125)
评论(0)
推荐(0)
摘要:
1 ``` 2 class Solution{ 3 string result; 4 public: 5 //根据数组前一个数,count and say 构造出后一个数 6 void generate(string s,string &result) 7 ... 阅读全文
posted @ 2014-10-27 21:41
羽加迪姆勒维奥萨
阅读(243)
评论(0)
推荐(0)
摘要:
闲着没事,做两道题玩玩,有一些地方还是有一些意思的;对称树 1 ```c++ 2 bool isSymmetric(TreeNode *root) 3 { 4 //约定空树是对称的 5 if(root==NULL) 6 return true; 7 else 8 return isEqual(roo... 阅读全文
posted @ 2014-10-27 21:31
羽加迪姆勒维奥萨
阅读(355)
评论(0)
推荐(0)

浙公网安备 33010602011771号