7 算法导论我去

尚未进行身份认证

我要认证

我喜欢写代码^-^

等级
TA的排名 6w+

Go concurrent crawler

下面是a tour of go 中最后一个练习的解法,本文使用了真正的网络io来运行爬虫,由于没有对连接数做限制,所以当depth为3时会发生错误package mainimport ( "fmt" "log" "strings" "sync" "github.com/PuerkitoBio/goquery")type Fetcher interface {

2017-12-29 20:19:18

rot13Reader

package mainimport ( "io" "os" "strings")type rot13Reader struct { r io.Reader}func (rot rot13Reader) Read(b []byte) (n int, err error){ left:=len(b) for{ length,stat

2017-12-27 18:23:57

397. Longest Increasing Continuous Subsequence

class Solution: """ @param: A: An array of Integer @return: an integer """ def longestIncreasingContinuousSubsequence(self, A): # write your code here if len(A)==0:

2017-12-24 12:12:31

115. Unique Paths II

class Solution: """ @param: obstacleGrid: A list of lists of integers @return: An integer """ def uniquePathsWithObstacles(self, obstacleGrid): # write your code here

2017-12-24 12:04:53

114. Unique Paths

class Solution: """ @param: m: positive integer (1 <= m <= 100) @param: n: positive integer (1 <= n <= 100) @return: An integer """ def uniquePaths(self, m, n): # write

2017-12-24 11:55:24

111. Climbing Stairs

class Solution: """ @param n: An integer @return: An integer """ def climbStairs(self, n): # write your code here if n==0: return 0 if n==1:

2017-12-24 11:46:53

110.Minimum Path Sum

class Solution: """ @param: grid: a list of lists of integers @return: An integer, minimizes the sum of all numbers along its path """ def minPathSum(self, grid): # write yo

2017-12-24 11:41:41

109.triangle

class Solution: """ @param: triangle: a list of lists of integers @return: An integer, minimum path sum """ def minimumTotal(self, triangle): # write your code here

2017-12-24 11:31:50

514. Paint Fence

class Solution {public: /* * @param n: non-negative integer, n posts * @param k: non-negative integer, k colors * @return: an integer, the total number of ways */ int numWa

2017-12-24 11:16:09

kmp算法

#define MAX 10000void getNext(char *p,int next[]){ int p_len=strlen(p); next[0]=-1; next[1]=0; for (int i=2;i<p_len;i++){ int q=next[i-1]; while (q!=0 && p[q]!=p[i-1])

2017-12-23 00:20:48

最长递增子序列(nlogn)

#define MAX 1000000int find(int a[],int x,int l,int r){ while (l<=r){ int mid=(l+r)/2; if (a[mid]==x) return mid; if (a[mid]<x) l=mid+1; els

2017-12-22 19:30:05

排序算法大合集

#include<stdlib.h>#include<unistd.h>#include<stdio.h>#include<unistd.h>#include<sys/wait.h>#include<time.h>#define MAX 10000int check(int a[],int n){ for (int i=0;i<n-1;i++) if (a[i]>

2017-12-22 14:58:20

4.1.3求值器数据结构

;4.12,这里的用了一个通用的在框架中寻找变量的过程,不过这个过程不能用在4.13中的make-unbound!里(define (lookup-var-in-frame var vars vals) (cond ((null? vars) false) ((eq? var (car vars)) (cons vars vals)) (else (lookup

2016-07-16 11:46:04

4.1.2表达式的表示

表达式的表示

2016-07-10 21:15:29

函数式程序的模块化和对象的模块化

(define random-init 1)(define (rand-update x) (remainder (+ (* 13 x) 5) 24))(define (random-numbers op-stream) (define (numbers last-value op-stream) (let ((op (stream-car op-stream)))

2016-06-20 11:51:23

流和延时求值

;书上的let并不是必须的(define (integral delayed-integrand initial-value dt) (define int (cons-stream initial-value (add-streams (scale-stream (force delaye

2016-06-18 07:33:06

序对的无穷流

(define (interleave s1 s2) (if (empty-stream? s1) s2 (cons-stream (stream-car s1) (interleave s2 (stream-cdr s1)))))(define (pairs s t) (cons-stream (list (stream-ca

2016-06-08 12:55:58

流计算模式的使用

;系统地将迭代操作方式表示为流过程(define (sqrt-stream x) (define guesses (cons-stream 1.0 (stream-map (lambda (guess) (/ (+ guess (/ x guess)) 2)) guesses)))

2016-06-05 15:39:24

流(3.5.1~3.5.2)

;流实现的行为方式;delay和force的实现(define (memo-proc proc) (let ((already-run? false) (result false)) (lambda () (if already-run? result (begin (set! already-run? tr

2016-06-05 11:25:42

约束的传播

;连接器的表示;user不需要也不能添加进constraints表里面,并且只有实现connect过的constraint才能进行set-value!(define (make-connector) (let ((value false) (informant false) (constraints '())) (define (set-my-value! new-value set

2016-05-30 00:16:08

查看更多

勋章 我的勋章
  • 持之以恒
    持之以恒
    授予每个自然月内发布4篇或4篇以上原创或翻译IT博文的用户。不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!