摘要: 好久没写博客了,这段时间已经忙成狗,半年时间就这么没了,必须得做一下总结否则白忙。接下去可能会有一系列的总结,都是关于定向爬虫(干了好几个月后才知道这个名词)的构建方法,实现平台是Node.JS。 背景 一般爬虫的逻辑是这样的,给定一个初始链接,把该链接的网页下载保存,接着分析页面中的链接,找到目标 阅读全文
posted @ 2015-05-17 19:05 月窟仙人 阅读(662) 评论(0) 推荐(0) 编辑
摘要: 好久没写博客了,这段时间已经忙成狗,半年时间就这么没了,必须得做一下总结否则白忙。接下去可能会有一系列的总结,都是关于定向爬虫(干了好几个月后才知道这个名词)的构建方法,实现平台是Node.JS。 背景 一般爬虫的逻辑是这样的,给定一个初始链接,把该链接的网页下载保存,接着分析页面中的链接,找到目标 阅读全文
posted @ 2015-05-17 18:32 月窟仙人 阅读(1314) 评论(2) 推荐(4) 编辑
摘要: 题目:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the". 1 public String reverseWor... 阅读全文
posted @ 2014-07-12 15:42 月窟仙人 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents the number123.Find the total sum of all root-to-leaf numbers.For example, 1 / \ 2 3The root-to-leaf path1->2represents the number1 阅读全文
posted @ 2013-12-18 15:05 月窟仙人 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Here are few examples.[1,3,5,6], 5 → 2[1,3,5,6], 2 → 1[1,3,5,6], 7 → 4[1,3,5,6], 0 → 0这个题目比较简单,也就是二分作 阅读全文
posted @ 2013-12-18 14:18 月窟仙人 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 题目:Implement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input string (not partial).The function prototype should be:boo 阅读全文
posted @ 2013-12-17 21:44 月窟仙人 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 题目:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6.The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 阅读全文
posted @ 2013-12-16 15:41 月窟仙人 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题目:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0.For example, givenn= 2, return[0,1,3,2]. Its gray cod 阅读全文
posted @ 2013-12-15 16:43 月窟仙人 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题目:A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number of ways to decode it.For example,Given encoded message"12", it 阅读全文
posted @ 2013-12-15 15:32 月窟仙人 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题目:Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space.开始理解题目的点问题,以为是漏掉的一个数,其实应该是第一个漏掉的自然数,这里自然数当然不包括0。所以只要从1开始每次加一看哪一个数没有出现在列表中就得到结果了,关键是怎么依次查呢?当时没想到办法,后来有 阅读全文
posted @ 2013-12-12 18:37 月窟仙人 阅读(174) 评论(0) 推荐(0) 编辑