
算法
文章平均质量分 74
路人甲wttttt
这个作者很懒,什么都没留下…
展开
-
leetcode题解
一道题目的状态分为三种:[未掌握],[已掌握],[已巩固]第一次无法AC的题目,标记为未掌握。第二天可以默写代码的题目,改标志为已掌握。一个星期复习时依然可以写出代码的题目,标记为已巩固。++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++31. Next Permutation [未掌握]原创 2016-12-02 12:09:42 · 823 阅读 · 0 评论 -
DAY22:leetcode #36 Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially fille原创 2016-11-07 18:33:42 · 258 阅读 · 0 评论 -
DAY22:leetcode #52 N-Queens II
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.Subscribe to see which companies asked this questionclass原创 2016-11-06 15:28:29 · 237 阅读 · 0 评论 -
DAY22:leetcode #51 N-Queens
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle原创 2016-11-06 15:24:33 · 330 阅读 · 0 评论 -
DAY21:leetcode #50 Pow(x, n)
Implement pow(x, n).Subscribe to see which companies asked this questionclass Solution(object): def myPow(self, x, n): """ :type x: float :type n: int :rt原创 2016-11-05 14:44:24 · 338 阅读 · 0 评论 -
DAY21:leetcode #49 Group Anagrams
Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]Note: Al原创 2016-11-05 14:09:05 · 217 阅读 · 0 评论 -
DAY20:leetcode #45 Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal i原创 2016-11-04 20:07:54 · 254 阅读 · 0 评论 -
DAY21:leetcode #48 Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?Subscribe to see which companies asked this que原创 2016-11-05 13:48:02 · 270 阅读 · 0 评论 -
DAY20:leetcode #55 Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i原创 2016-11-04 12:05:38 · 232 阅读 · 0 评论 -
DAY19:leetcode #39 Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numb原创 2016-11-04 11:36:55 · 279 阅读 · 0 评论 -
DAY18:leetcode #43 Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string.Note:The numbers can be arbitrarily large and are non-negative.Converting the input string to integ原创 2016-11-04 11:35:20 · 207 阅读 · 0 评论 -
DAY17:leetcode #34 Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found原创 2016-11-04 11:32:58 · 243 阅读 · 0 评论 -
DAY17:leetcode #42 Trapping Rain Water
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]原创 2016-11-04 11:31:30 · 224 阅读 · 0 评论 -
DAY16:leetcode #33 Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array retur原创 2016-11-04 11:29:21 · 218 阅读 · 0 评论 -
DAY15:leetcode #35 Search Insert Position
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.原创 2016-11-04 11:27:58 · 200 阅读 · 0 评论 -
DAY15:leetcode #29 Divide Two Integers
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.Subscribe to see which companies asked this questionclass Solution(objec原创 2016-11-04 11:26:36 · 253 阅读 · 0 评论 -
DAY14:leetcode #38 Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as原创 2016-11-04 11:22:00 · 237 阅读 · 0 评论 -
DAY20:leetcode #47 Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[ [1,1,2], [1,2,1], [2,1原创 2016-11-04 10:00:00 · 185 阅读 · 0 评论 -
DAY22:leetcode #37 Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudoku原创 2016-11-07 22:14:34 · 282 阅读 · 0 评论 -
DAY23:leetcode #54 Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]原创 2016-11-08 16:17:49 · 240 阅读 · 0 评论 -
DAY14:leetcode #58 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is原创 2016-11-04 11:24:34 · 214 阅读 · 0 评论 -
DAY27:leetcode #23 Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Subscribe to see which companies asked this question# Definition for singly-linked list.# c原创 2016-11-28 16:41:38 · 336 阅读 · 0 评论 -
DAY27:leetcode #25 Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is原创 2016-11-28 16:10:00 · 325 阅读 · 0 评论 -
DAY27:leetcode #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.Note: The solution原创 2016-11-28 14:40:09 · 263 阅读 · 0 评论 -
DAY26:leetcode #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.Example:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.原创 2016-11-27 19:34:35 · 326 阅读 · 0 评论 -
DAY29:leetcode #32 Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",原创 2016-12-01 16:29:13 · 335 阅读 · 0 评论 -
DAY25:leetcode #53 Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-1,2,1] ha原创 2016-11-15 10:45:39 · 319 阅读 · 0 评论 -
Scrapy源码分析(三):信号管理器SignalManager
类的位置scrapy.signalmanager.SignalManager。主要是对pydispatch.dispatcher的一层封装。首先来看看pydispatch.dispatcher都有哪些功能:项目主页这个模块主要提供了消息的发送和接收功能,主页的示例:To set up a function to receive signals:from pydispatch原创 2016-11-29 23:41:26 · 2340 阅读 · 0 评论 -
DAY28:leetcode #41 First Missing Positive
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原创 2016-11-29 14:11:18 · 369 阅读 · 0 评论 -
DAY24:leetcode #67 Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".Subscribe to see which companies asked this questionclass Solution(object)原创 2016-11-10 16:06:35 · 319 阅读 · 0 评论 -
DAY24:leetcode #66 Plus One
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.Subscribe to see原创 2016-11-10 15:51:23 · 282 阅读 · 0 评论 -
DAY24:leetcode #64 Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at原创 2016-11-10 13:53:38 · 272 阅读 · 0 评论 -
DAY24:leetcode #63 Unique Paths II
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the原创 2016-11-10 13:23:45 · 268 阅读 · 0 评论 -
DAY24:leetcode #62 Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the原创 2016-11-10 13:10:02 · 237 阅读 · 0 评论 -
DAY23:leetcode #60 Permutation Sequence
The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""3原创 2016-11-08 23:44:37 · 237 阅读 · 0 评论 -
DAY23:leetcode #59 Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [原创 2016-11-08 20:14:57 · 231 阅读 · 0 评论 -
DAY23:leetcode #56 Merge Intervals
Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].Subscribe to see which companies asked this qu原创 2016-11-08 17:03:40 · 395 阅读 · 0 评论 -
DAY20:leetcode #46 Permutations
Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1原创 2016-11-04 09:40:00 · 179 阅读 · 0 评论 -
DAY19:leetcode #40 Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combina原创 2016-09-04 11:35:18 · 289 阅读 · 0 评论 -
DAY6:leetcode #11 Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin原创 2016-04-26 10:12:05 · 331 阅读 · 0 评论