摘要:
class Solution {public: vector<vector<int>> generate(int numRows) { vector<vector<int>>result; if(numRows<=0) return result; int n = numRows; for(int 阅读全文
posted @ 2015-12-10 15:59
雪之灵
阅读(116)
评论(0)
推荐(0)
摘要:
class Solution {public: vector plusOne(vector& digits) { int val= 1; int length = digits.size();//注意数字的高位为digits[0],低位在digits[length-1] for(int i = le... 阅读全文
posted @ 2015-12-10 15:56
雪之灵
阅读(188)
评论(0)
推荐(0)
摘要:
class Solution { /*本质上在一列数组中取出一个或多个不相邻数,使其和最大。那么我们对于这类求极值的问题首先考虑动态规划Dynamic Programming来解,我们维护一个一位数组dp,其中dp[i]表示到i位置时不相邻数能形成的最大和,经过分析,我们可以得到递推公式dp[i] ... 阅读全文
posted @ 2015-12-10 15:53
雪之灵
阅读(137)
评论(0)
推荐(0)
摘要:
class Solution {public: int removeDuplicates(vector& nums) { int length = nums.size(); int size= 0; if(length<=1) return length; for(int i= 1;i<length... 阅读全文
posted @ 2015-12-10 15:51
雪之灵
阅读(112)
评论(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: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)
摘要:
/*** 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:14
雪之灵
阅读(107)
评论(0)
推荐(0)
摘要:
class Solution {public: int romanToInt(string s) { int length = s.size(); int result = 0; int pre =getnum (s[0]); for (int i = 1 ;i<length ;i++) {int ... 阅读全文
posted @ 2015-12-10 15:12
雪之灵
阅读(130)
评论(0)
推荐(0)
摘要:
For example, the 32-bit integer ’11' has binary representation00000000000000000000000000001011, so the function should return 3.class Solution {public... 阅读全文
posted @ 2015-12-10 15:06
雪之灵
阅读(125)
评论(0)
推荐(0)
摘要:
_______6______ / \ ___2__ ___8__ / \ / \ 0 _4 7 9 / \ 3 ... 阅读全文
posted @ 2015-12-10 15:05
雪之灵
阅读(116)
评论(0)
推荐(0)

浙公网安备 33010602011771号