- 博客(8)
- 收藏
- 关注
原创 Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),
2016-03-05 22:17:19 358
原创 LeetCode Binary Tree Right Side View
层次遍历我的想法:层序遍历,然后输出每一层最右边的节点代码如下:class Solution {public: vector rightSideView(TreeNode* root) { vector result; vector high; vector low; if(root==NULL) return re
2016-03-05 12:53:29 283
原创 Leetcode House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house
2016-03-03 23:16:11 367
原创 @property总结
参考网址:http://blog.csdn.net/dfqin/article/details/11669993http://www.linuxidc.com/Linux/2014-03/97744.htmhttp://www.cnblogs.com/andyque/archive/2011/08/03/2125728.htmlhttp://blog.csdn.net/dfqi
2016-03-03 20:38:14 336
原创 LeetCode Power of Two
Given an integer, write a function to determine if it is a power of two.若一个数字是2的幂,那么它的二进制表示形式里面只有一个1,那么n-1刚好是除了为1的那位之外,其余所有位都为1的数字,举个例子,4的二进制为100,而3 的二进制为011,综上,如果一个数字n&(n-1)==0那么这个数字就是2的幂。class S
2016-03-03 13:36:15 335
原创 Leetcode Number of Digit One
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Return 6, because digit 1 occurred in the followin
2016-03-03 10:42:54 275
原创 LeetCode Insertion Sort List
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* in
2016-03-02 10:51:23 378
原创 Leetcode Swap Nodes in Pairs
递归做法:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListN
2016-03-02 09:16:13 314
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人