自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(40)
  • 资源 (1)
  • 收藏
  • 关注

原创 Leetcode Word Ladder II

Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) frombeginWord to endWord, such that:Only one letter can be changed at a timeEa

2017-07-26 10:40:44 226

转载 python爬虫-多进程

python当中因为一个进程同一时刻只能执行一个线程,所以多线程效率并不高,要提高效率需要使用多进程。Process([group [, target [, name [, args [, kwargs]]]]])target表示调用对象,你可以传入方法的名字args表示被调用对象的位置参数元组,比如target是函数a,他有两个参数m,n,那么args就传入(m, n)即

2017-07-21 16:27:33 401

转载 python爬虫-正则表达式

正则表达式是十分高效而优美的匹配字符串工具,一定要好好掌握。利用正则表达式可以轻易地从返回的页面中提取出我们想要的内容。1)贪婪模式与非贪婪模式python默认是贪婪模式。贪婪模式,总是尝试匹配尽可能多的字符;非贪婪模式,总是尝试尽可能少的字符。一般采用非贪婪模式来提取。2)反斜杠问题正则表达式里使用"\"作为转义字符,这会造成困扰。如果你要匹配文中的字符"\"

2017-07-21 11:34:42 251

转载 python爬虫利器-request库

request库比urllib2库更为高级,因为其功能更强大,更易于使用。使用该库可以十分方便我们的抓取。基本请求r = requests.get('http://cuiqingcai.com')r = requests.post("http://httpbin.org/post")r = requests.put("http://httpbin.org/put")r =

2017-07-21 09:50:14 291

转载 python爬虫-cookie

Cookie指某些网站为了辨别用户身份,进行session跟踪而存储在用户本地终端上的数据(经过加密)。例如:网站的某些页面必须登录后才可以抓取,但你通过urllib2库保存我们登录该网站的Cookie,就可以对该页面进行抓取。cookielib提供可存储cookie的对象,通过本模块的CookieJar类的对象来捕获cookie并在后续连接请求是重新发送。1)抓取Co

2017-07-21 09:01:03 196

转载 python爬虫-异常处理

主要有两类异常 :URLError和HTTPErrorURLError:该异常发生的情况:1.网络无法连接2.连接不到特定服务器3.服务器不存在import urllib2 requset = urllib2.Request('http://www.xxxxx.com')try: urllib2.urlopen(request)except urll

2017-07-20 16:56:16 279

转载 Python爬虫-urllib库

通过构建一个request请求发送,然后获取回应response,也就是网页代码import urllib2request = urllib2.Request("www.baidu.com")response = urllib2.urlopen(request)pageCode = response.read().decode('gbk')数据传送分为两种方式:GE

2017-07-20 16:34:04 226

原创 Leetcode Surrounded Regions

Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into'X's in that surrounded region.For example,X X

2017-07-18 17:27:00 155

原创 Leetcode Word Ladder

Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWord to endWord, such that:Only one letter can be changed at a

2017-07-17 18:28:54 183

原创 Leetcode Palindrome Partitioning II

Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs.For example, given s = "aab",Return 1

2017-07-17 14:55:01 150

原创 Leetcode 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 least on

2017-07-17 11:18:34 234

原创 Leetcode gasstation

There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to it

2017-07-16 12:03:13 217

原创 Leetcode Max Points on a Line

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.暴力破解,通过记录hash方法来进行记录中间结果,代码如下:/** * Definition for a point. * struct Point { * int x

2017-07-14 15:20:02 171

原创 Leetcode Word Break II

Given a non-empty string s and a dictionarywordDict containing a list of non-empty words, add spaces ins to construct a sentence where each word is a valid dictionary word. You may assume the dict

2017-07-13 09:47:21 391

原创 Leetcode LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.get(key) - Get the value (will always be positive) of the key i

2017-07-13 08:54:31 278

原创 Leetcode Word Break

Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may as

2017-07-12 19:43:00 153

原创 Leetcode Evaluate Reverse Polish Notation

Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are +, -,*, /. Each operand may be an integer or another expression.Some examples: ["2", "1", "+",

2017-07-12 14:19:48 191

原创 Leetcode Sort List

Sort a linked list in O(n log n) time using constant space complexity.本题使用归并算法,但需要注意的是归并的终结条件。终结条件为head==NULL以及head->next==NULL,因为这两种情况下,程序都不会自动结束。代码如下:/** * Definition for singly-l

2017-07-12 10:24:38 167

原创 Leetcode Insertion Sort List

Sort a linked list using insertion sort.思路就跟数组的插入排序思想一致,但是因为链表的只能从前往后遍历且无法随机访问,所以操作比较复杂,需要小心处理。代码如下:/** * Definition for singly-linked list. * struct ListNode { * int val; * Li

2017-07-11 15:28:40 178

原创 Leetcode Binary Tree Postorder Traversal

Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solution is tri

2017-07-11 13:51:34 159

原创 Leetcode Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].Note: Recursive solution is triv

2017-07-11 10:41:56 181

原创 Leetcode Reorder List

Given a singly linked list L: L0?L1?…?Ln-1?Ln,reorder it to: L0?Ln?L1?Ln-1?L2?Ln-2?…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to {1,4

2017-07-11 10:05:22 156

原创 Leetcode Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Note: Do not modify the linked list.Follow up:Can you solve it without using extra space?

2017-07-10 16:55:43 160

原创 Leetcode Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?解题思路:分别设置两个指针one和two,遍历的时候,one=one->next,two=two->next->next,这样以不同速率进行遍历,如果该列表存在环的

2017-07-10 15:59:22 178

原创 Leetcode Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.最先想到就是遍历列表生成新的列表,但没有对random域进行

2017-07-10 15:22:16 170

原创 Leetcode Single Number II

Given an array of integers, every element appearsthree times except for one, which appears exactly once. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could y

2017-07-10 14:11:48 165

原创 Leetcode Palindrome Partitioning

Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return[ ["aa","b"],

2017-07-07 10:25:57 204

原创 Leetcode Single Number

Given an array of integers, every element appearstwice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extr

2017-07-07 08:58:00 217

原创 Leetcode 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, 2, 3,

2017-07-07 08:40:08 258

原创 Leetcode Populating Next Right Pointers in Each Node II

Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant extr

2017-07-06 16:17:29 143

原创 Leetcode Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number123.Find the total s

2017-07-06 15:19:06 172

原创 Leetcode Binary Tree Maximum Path Sum

Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The pa

2017-07-06 09:39:33 152

原创 Leetcode Valid Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a pa

2017-07-05 16:23:40 131

原创 Leetcode Best Time to Buy and Sell Stock II

Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one

2017-07-05 14:39:17 129

原创 Leetcode Triangle

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,

2017-07-05 14:02:49 126

原创 Leetcode Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2017-07-05 11:03:48 127

原创 Leetcode Pascal's Triangle II

ven an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].代码如下:class Solution {public: vector getRow(int rowIndex) { vector pre

2017-07-05 10:25:54 183

原创 Leetcode Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]主要的是要找到其中的规律,

2017-07-05 09:51:14 119

原创 Leetcode Populating Next Right Pointers in Each Node

Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node. If the

2017-07-05 09:05:33 166

原创 Leetcode Distinct Subsequences

Given a string S and a string T, count the number of distinct subsequences of S which equalsT.A subsequence of a string is a new string which is formed from the original string by deleting some

2017-07-04 10:43:23 174

《机qi学习shi战.pdf》高清中文版PDF+英文版PDF+源代码.zip

用于机器学习入门的资料 跟着源代码学习 一步一步掌握

2019-06-11

空空如也

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

TA关注的人

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