
leetcode
happylife39
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
226. Invert 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) {} * };原创 2016-08-22 20:21:07 · 172 阅读 · 0 评论 -
219. Contains Duplicate II
class Solution { public: bool containsNearbyDuplicate(vector& nums, int k) { //map原创 2016-08-23 11:26:13 · 212 阅读 · 0 评论 -
检查一个数是不是回文数,很巧妙地方法
class Solution { public: bool isPalindrome(int x) { if(x<0|| (x!=0 &&x%10==0)) return false; int sum=0; while(x>sum) { sum = sum*10+x%10; x =翻译 2016-10-09 17:01:34 · 451 阅读 · 0 评论 -
1. Two Sum
class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> result; if(nums.size()<2) return result; unordered_map<int ,int> m;原创 2016-11-20 15:34:09 · 288 阅读 · 0 评论 -
32. Longest Valid Parentheses
class Solution { public: int longestValidParentheses(string s) { //使用DP,vector<int> res(s.size()), res[i]代表从s[j->i]的匹配圆括号数目 int n = s.size(); if(n<=1) return 0;原创 2016-11-21 14:44:21 · 238 阅读 · 0 评论 -
Sort List(归并排序)
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* sor原创 2016-11-21 17:05:24 · 309 阅读 · 0 评论