- 博客(7)
- 资源 (6)
- 收藏
- 关注
原创 [Leetcode]Palindrome Number
class Solution { public: bool isPalindrome(int x) { if(x<0) return false; if(x<10) return true; int n = 0; int y = x; while(y){ n++;
2016-09-30 11:28:01 179
原创 [Leetcode] Pascal's Triangle II
Pascal's Triangle II Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k)
2016-09-30 11:06:32 156
原创 Implement Queue using Stacks
用两个栈来操作,t存储队列的逆序,每次加入新元素就倒序使用s class Queue { public: // Push element x to the back of queue. void push(int x) { stack s; while(!t.empty()) { s.push(t.top());
2016-09-29 11:19:24 262
原创 [Leetcode] Remove Duplicates from Sorted Array
class Solution { public: int removeDuplicates(vector& nums) { if(nums.size() == 0) return 0; stack s; sort(nums.begin(),nums.end()); s.push(nums[0]); for(au
2016-09-29 10:49:18 203
原创 [Leetcode] Balanced Binary Tree
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ clas
2016-09-28 20:56:30 162
原创 [Leetcode] Binary Tree Level Order Traversal II
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ clas
2016-09-28 12:17:33 198
原创 [Leetcode] Symmetric
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ clas
2016-09-27 11:02:23 231
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人