06 2016 档案

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 胖胖的乓乓 阅读(123) 评论(0) 推荐(0)

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

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

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 胖胖的乓乓 阅读(90) 评论(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 胖胖的乓乓 阅读(114) 评论(0) 推荐(0)

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 胖胖的乓乓 阅读(105) 评论(0) 推荐(0)

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 胖胖的乓乓 阅读(110) 评论(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 胖胖的乓乓 阅读(99) 评论(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 胖胖的乓乓 阅读(86) 评论(0) 推荐(0)

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 胖胖的乓乓 阅读(127) 评论(0) 推荐(0)

300 Longest Increasing Subsequence
摘要:class Solution {public: int lengthOfLIS(vector& nums) { int length=nums.size(); if(length==0){ return 0; } int cont=0; int ... 阅读全文

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

全排列
摘要:全排列的应用很广,比如路径全部输出 以前一直用递归写的全排列,今天发现可以用C++ STL 实现 //递归方法#include#include#includeusing namespace std;char a[10];int n;void fuck(char *b,int k){ if(k... 阅读全文

posted @ 2016-06-16 16:04 胖胖的乓乓 阅读(173) 评论(0) 推荐(0)

Python函数式练习
摘要:def calc_prod(lst): def prod(): def mul_(a,b): return a*b return reduce(mul_,lst) return prodf = calc_prod([1, 2, 3,... 阅读全文

posted @ 2016-06-03 11:15 胖胖的乓乓 阅读(109) 评论(0) 推荐(0)

设计模式07_装饰模式
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication1{ abs... 阅读全文

posted @ 2016-06-02 17:06 胖胖的乓乓 阅读(110) 评论(0) 推荐(0)

设计模式06_桥接模式
摘要:设计模式学习笔记_桥接模式 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 桥接_咖啡加糖{ ... 阅读全文

posted @ 2016-06-02 15:47 胖胖的乓乓 阅读(120) 评论(0) 推荐(0)

设计模式05_抽象工厂模式
摘要:学习设计模式笔记之_抽象模式 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 抽象__汉堡可乐{ ... 阅读全文

posted @ 2016-06-02 14:58 胖胖的乓乓 阅读(131) 评论(0) 推荐(0)

Python__实现队列
摘要:Python__实现队列 class Queue(): def __init__(qu,size): qu.queue=[]; qu.size=size; qu.head=-1; qu.tail=-1; def Empty(qu... 阅读全文

posted @ 2016-06-01 23:29 胖胖的乓乓 阅读(134) 评论(0) 推荐(0)

Python 实现栈
摘要:#coding=utf-8class Stack(): def __init__(st,size): st.stack=[]; st.size=size; st.top=-1; def push(st,content): if ... 阅读全文

posted @ 2016-06-01 23:15 胖胖的乓乓 阅读(183) 评论(0) 推荐(0)

导航