上一页 1 2 3 4 5 6 7 ··· 10 下一页

2016年7月7日

06_ Palindrome Number

摘要: 题目点我查看~……~ /* 注意负数不被看作回文数*/class Solution {public: bool isPalindrome(int x) { int str[30]; int cur=0; if(x<0){ ... 阅读全文

posted @ 2016-07-07 22:21 胖胖的乓乓 阅读(101) 评论(0) 推荐(0) 编辑

2016年6月29日

Add Two Numbers

摘要: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a sing... 阅读全文

posted @ 2016-06-29 10:55 胖胖的乓乓 阅读(112) 评论(0) 推荐(0) 编辑

2016年6月26日

KMP

摘要: 1. 首先,字符串"BBC ABCDAB ABCDABCDABDE"的第一个字符与搜索词"ABCDABD"的第一个字符,进行比较。因为B与A不匹配,所以搜索词后移一位。 2. 因为B与A不匹配,搜索词再往后移。 3. 就这样,直到字符串有一个字符,与搜索词的第一个字符相同... 阅读全文

posted @ 2016-06-26 16:05 胖胖的乓乓 阅读(159) 评论(0) 推荐(0) 编辑

2016年6月25日

Leetcode 1.Two Sum

摘要: 暴力可过,复杂度达到了n^2 用map,复杂度为O(nlogn) //暴力版本class Solution {public: vector twoSum(vector& nums, int target) { vectoranswer; for(int i... 阅读全文

posted @ 2016-06-25 18:39 胖胖的乓乓 阅读(81) 评论(0) 推荐(0) 编辑

Leetcode 202. Happy Number

摘要: 202. Happy Number Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Startin... 阅读全文

posted @ 2016-06-25 17:44 胖胖的乓乓 阅读(111) 评论(0) 推荐(0) 编辑

2016年6月19日

LeetCode 242. Valid Anagram

摘要: 对俩个字符串各自扫一遍class Solution {public: bool isAnagram(string s, string t) { int len_s=s.length(); int len_t=t.length(); if(len_s... 阅读全文

posted @ 2016-06-19 10:13 胖胖的乓乓 阅读(100) 评论(0) 推荐(0) 编辑

2016年6月18日

LeetCode 64. Minimum Path Sum

摘要: class Solution {public: int minPathSum(vector>& grid) { int n=grid.size(); int m=grid[0].size(); int dp[n+1][m+1]; me... 阅读全文

posted @ 2016-06-18 20:48 胖胖的乓乓 阅读(106) 评论(0) 推荐(0) 编辑

LeetCode 63. Unique Paths II

摘要: class Solution {public: int uniquePathsWithObstacles(vector>& obstacleGrid) { if(obstacleGrid.size()==0){ return 0; } ... 阅读全文

posted @ 2016-06-18 20:25 胖胖的乓乓 阅读(95) 评论(0) 推荐(0) 编辑

LeetCode 62. Unique Paths

摘要: class Solution {public: int nn,mm; int uniquePaths(int m, int n) { num=0; nn=m,mm=n; int dp[101][101]; for(int... 阅读全文

posted @ 2016-06-18 20:07 胖胖的乓乓 阅读(81) 评论(0) 推荐(0) 编辑

2016年6月17日

334. Increasing Triplet Subsequence

摘要: //贪心class Solution {public: bool increasingTriplet(vector& nums) { int length=nums.size(); if(length==0){ return 0; } int ... 阅读全文

posted @ 2016-06-17 21:17 胖胖的乓乓 阅读(123) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 ··· 10 下一页

导航