自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(21)
  • 收藏
  • 关注

原创 黑板客爬虫闯关

这个爬虫闯关挺适合入门的,主要是爬取静态网页以及模拟登陆。 一共有5关,重点讲第4关和第5关。 1-3关第1关是每个页面都带有一串数字,然后要把这串数字替换到url上再访问,从而进入下一个地址获取下一串数字,直至过关。对于了解html的人来说不难,使用beautifulsoup+lxml解析获取到的html即可。第2关是猜密码,密码是0-30内的一个数字,这里就用到post方法了先手动在网页

2017-07-13 14:29:10 413

原创 算法概论 课后习题 8.3 证明

EX 8.3 STINGY SAT is the following problem: given a set of clauses (each a disjunction of literals) and an integer k, find a satisfying assignment in which at most k variables are true, if such an a

2017-07-04 21:08:51 265

原创 LeetCode Algorithms 32. Longest Valid Parentheses 题解

题目:求最长的匹配括号子串长度匹配括号,使用栈是最好的。push左括号,遇到右括号就把最上面的左括号pop出来,每pop一个左括号就是一次匹配。那么现在问题就是怎么确定子串的长度,先考虑特殊情况,如果进行push,pop之后栈是空的,那么说明字符串是括号完全匹配的,那么最长的匹配长度就是它本身的长度。如果最后栈不为空,那么会有一些不匹配的括号留下,而这些不匹配的括号,恰恰可以帮我们把子串分割成不同的

2017-07-04 16:51:25 263

原创 LeetCode Algorithms 226. Invert Binary Tree 题解

题目:反转二叉树 Trivia: This problem was inspired by this original tweet by Max Howell: Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a

2017-06-22 09:54:49 277

原创 LeetCode Algorithms 78. Subsets 题解

题目:给定一个集合,返回其所有子集。求一个集合的powset,共有2^n个子集,只要判断每个元素是否在子集里,每个元素有两种可能,存在在或不存在,因此共有2^n个子集。结合这个思想,我们可以这样得到子集:遍历到新的元素e时,都存在子集包含e或者不包含e的可能, 1. 如果不包含e,则这些子集都是当前所有子集 2. 如果包含e,则这些子集是当前所有子集加上此元素写成代码如下:vector<vect

2017-06-12 00:08:47 210

原创 LeetCode Algorithms 233. Number of Digit One 题解

题目:Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.

2017-06-05 13:20:11 375

原创 LeetCode Algorithms 98. Validate Binary Search Tree 题解

题目:判断一棵树是否为BST树 因为BST广为人知,所以就不搬原文了,其中节点的数值是int类型。对于BST树,对它做中序遍历即可输出排好序的一串数字,那么对于这个题目就有两个思路: 1. 对这棵树做一次中序遍历,输出一个数组,然后判断数组是否有序 2. 同样是做中序遍历,但只比较当前节点的数值与前一个节点的数值大小对于第一种思路,很好实现,先做一次中序遍历,中序遍历有递归与非递归的实现,递归

2017-06-01 15:39:17 312

原创 LeetCode Algorithms 76. Minimum Window Substring 题解

题目: Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = “ADOBECODEBANC” T = “ABC” Minimum wind

2017-05-22 01:21:23 432

原创 LeetCode Algorithms 135. Candy 题解

There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements: Each child must have at leas

2017-05-15 12:26:36 482

原创 LeetCode Algorithms 128. Longest Consecutive Sequence 题解

Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [1,

2017-05-07 17:30:24 245

原创 LeetCode Algorithms 5. Longest Palindromic Substring 题解

题目: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.找出给定字符串的最长回文子串,首先想到使用暴力解法,第一层循环从字符串头遍历到尾,第二层循环从尾部开始到头部,第三层循环检验是否是回文。这样的话时间复杂度很

2017-05-01 22:44:16 234

原创 LeetCode Algorithms 113. Path Sum II 题解

题目 Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum. For example: Given the below binary tree and sum = 22, 5

2017-04-21 00:11:55 332

原创 LeetCode Algorithms 7. Reverse Integer 题解

题目: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321对输入的整数进行翻转,保留符号,与之前做过的atoi有点类似。算法大致思想: 1. 对于输入的x,先mod10,得到余数, 2. 然后对上一次计算的结果(结果最开始是0)做进位(乘

2017-04-18 01:06:11 203

原创 LeetCode Algorithms 50. Pow(x, n) 题解

题目: Implement pow(x, n).没有特殊要求,根据题目要求的输入,是(double x, int n),那么最大的阶数是MAX_INT,最小的阶数是MIN_INT。首先想到的是,一个while循环,res*=x就可以了,但是会超时TLE。那么就要想一个比O(n)复杂度更小的算法了。不难想到,计算过程中,有的计算结果是可以储存下来供后面的计算用的,比如已经计算了x^3, 那么x

2017-04-09 11:41:19 326

原创 LeetCode Algorithms 292. Nim Game 题解

题目: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will

2017-04-03 23:41:01 304

原创 LeetCode Algorithms 8. String to Integer (atoi) 题解

题目 Implement atoi to convert a string to an integer.

2017-03-25 13:59:52 258

原创 LeetCode Algorithms 18. 4Sum 题解

题目: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.

2017-03-19 01:26:31 193

原创 LeetCode Algorithms 279. Perfect Squares 题解

题目 Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n.

2017-03-11 18:18:33 634

原创 LeetCode Algorithms 3. Longest Substring Without Repeating Characters 题解

题目: Given a string, find the length of the longest substring without repeating characters.

2017-03-03 16:52:39 372

原创 LeetCode Algorithms 2. Add Two Numbers 题解

题目: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and

2017-02-25 19:54:06 338

转载 欢迎使用CSDN-markdown编辑器

欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl

2017-02-25 18:18:34 135

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除