摘要: /*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode(int x) : val(x), left(NULL), right(N... 阅读全文
posted @ 2015-12-10 15:48 雪之灵 阅读(104) 评论(0) 推荐(0)
摘要: Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文
posted @ 2015-12-10 15:43 雪之灵 阅读(117) 评论(0) 推荐(0)
摘要: /*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode(int x) : val(x), left(NULL), right(N... 阅读全文
posted @ 2015-12-10 15:42 雪之灵 阅读(168) 评论(0) 推荐(0)
摘要: For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees ofeverynode never differ by more th... 阅读全文
posted @ 2015-12-10 15:38 雪之灵 阅读(136) 评论(0) 推荐(0)
摘要: class Solution {public: bool isPowerOfTwo(int n) { //一定要处理n为0的情况 if(n==0) return false; while(n%2==0)n=n/2; if (n==1) return true; else return false; ... 阅读全文
posted @ 2015-12-10 15:35 雪之灵 阅读(135) 评论(0) 推荐(0)
摘要: /*** Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode(int x) : val(x), next(NULL) {}* };*/class Solution {pu... 阅读全文
posted @ 2015-12-10 15:33 雪之灵 阅读(110) 评论(0) 推荐(0)
摘要: class Queue {public: stacksta1; stacksta2; // Push element x to the back of queue. /* 入栈:把元素push到sta1中; 出栈:sta2作为辅助栈,如果sta2不为空,则把sta2中的元素挨个出站,然后把sta1的... 阅读全文
posted @ 2015-12-10 15:31 雪之灵 阅读(127) 评论(0) 推荐(0)
摘要: Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For example,6, 8are ugly while14is not ugly since it includes another prime... 阅读全文
posted @ 2015-12-10 15:27 雪之灵 阅读(123) 评论(0) 推荐(0)
摘要: Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu... 阅读全文
posted @ 2015-12-10 15:22 雪之灵 阅读(140) 评论(1) 推荐(0)
摘要: You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文
posted @ 2015-12-10 15:17 雪之灵 阅读(170) 评论(0) 推荐(0)