06 2014 档案

摘要:最简单的不相交集的实现,来自MAW的《数据结构与算法分析》。代码:class DisjSet: def __init__(self, NumSets): self.S = [0 for i in range(NumSets+1)] def SetUnion(self, S,... 阅读全文
posted @ 2014-06-17 11:09 南郭子綦 阅读(602) 评论(0) 推荐(0) 编辑
摘要:二叉树的插入与删除,来自Mark Allen Weiss的《数据结构与算法分析》。# Definition for a binary tree nodeclass TreeNode: def __init__(self, x): self.val = x self... 阅读全文
posted @ 2014-06-16 22:23 南郭子綦 阅读(2134) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/add-two-numbers/题意:You are given two linked lists representing two non-negative numbers. The digits are stored i... 阅读全文
posted @ 2014-06-13 16:06 南郭子綦 阅读(9039) 评论(3) 推荐(1) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/题意:Given a string, find the length of the longest substring witho... 阅读全文
posted @ 2014-06-13 14:56 南郭子綦 阅读(5111) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/reverse-nodes-in-k-group/题意:Given a linked list, reverse the nodes of a linked listkat a time and return its mod... 阅读全文
posted @ 2014-06-13 12:06 南郭子綦 阅读(3195) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/submissions/detail/5341904/题意:The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of ... 阅读全文
posted @ 2014-06-13 11:48 南郭子綦 阅读(4704) 评论(0) 推荐(1) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/merge-two-sorted-lists/题意:Merge two sorted linked lists and return it as a new list. The new list should be made... 阅读全文
posted @ 2014-06-13 11:26 南郭子綦 阅读(6650) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/rotate-list/题意:Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2... 阅读全文
posted @ 2014-06-13 11:19 南郭子綦 阅读(3693) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/minimum-window-substring/题意:Given a string S and a string T, find the minimum window in S which will contain all... 阅读全文
posted @ 2014-06-13 11:02 南郭子綦 阅读(4921) 评论(4) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/unique-paths-ii/题意:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many ... 阅读全文
posted @ 2014-06-13 09:57 南郭子綦 阅读(2957) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/unique-paths/题意:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The ... 阅读全文
posted @ 2014-06-13 09:43 南郭子綦 阅读(3422) 评论(1) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/maximal-rectangle/题意:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all... 阅读全文
posted @ 2014-06-12 16:53 南郭子綦 阅读(3136) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/largest-rectangle-in-histogram/题意:Givennnon-negative integers representing the histogram's bar height where the ... 阅读全文
posted @ 2014-06-12 15:12 南郭子綦 阅读(4608) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/decode-ways/题意:A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -... 阅读全文
posted @ 2014-06-12 14:33 南郭子綦 阅读(5266) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/gray-code/题意:The gray code is a binary numeral system where two successive values differ in only one bit.Given a... 阅读全文
posted @ 2014-06-12 13:33 南郭子綦 阅读(2677) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/题意:Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed... 阅读全文
posted @ 2014-06-12 12:00 南郭子綦 阅读(2344) 评论(1) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/题意:Given a sorted linked list, delete all nodes that have duplicate number... 阅读全文
posted @ 2014-06-12 11:25 南郭子綦 阅读(2634) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/题意:Given a sorted linked list, delete all duplicates such that each element a... 阅读全文
posted @ 2014-06-12 10:52 南郭子綦 阅读(3868) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/题意:Follow up for "Remove Duplicates":What if duplicates are allowed at mo... 阅读全文
posted @ 2014-06-12 10:49 南郭子綦 阅读(2812) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/reverse-linked-list-ii/题意:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Gi... 阅读全文
posted @ 2014-06-12 10:05 南郭子綦 阅读(3609) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/partition-list/题意:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes... 阅读全文
posted @ 2014-06-12 09:38 南郭子綦 阅读(3032) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/题意:Given a binary tree, find its maximum depth.The maximum depth is the number of n... 阅读全文
posted @ 2014-06-11 16:40 南郭子綦 阅读(3615) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/text-justification/题意:Given an array of words and a lengthL, format the text such that each line has exactlyLcha... 阅读全文
posted @ 2014-06-11 15:42 南郭子綦 阅读(2965) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/insert-interval/题意:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if ne... 阅读全文
posted @ 2014-06-11 15:17 南郭子綦 阅读(3120) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/merge-intervals/题意:Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6]... 阅读全文
posted @ 2014-06-11 15:10 南郭子綦 阅读(5164) 评论(3) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/maximum-subarray/题意:Find the contiguous subarray within an array (containing at least one number) which has the ... 阅读全文
posted @ 2014-06-11 14:51 南郭子綦 阅读(6195) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/jump-game-ii/题意:Given an array of non-negative integers, you are initially positioned at the first index of the ... 阅读全文
posted @ 2014-06-11 14:41 南郭子綦 阅读(3558) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/jump-game/题意:Given an array of non-negative integers, you are initially positioned at the first index of the arr... 阅读全文
posted @ 2014-06-11 14:35 南郭子綦 阅读(3377) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/wildcard-matching/题意:Implement wildcard pattern matching with support for'?'and'*'.'?' Matches any single charac... 阅读全文
posted @ 2014-06-11 14:18 南郭子綦 阅读(4924) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/regular-expression-matching/题意:Implement regular expression matching with support for'.'and'*'.'.' Matches any s... 阅读全文
posted @ 2014-06-11 13:32 南郭子綦 阅读(8423) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/multiply-strings/题意:Given two numbers represented as strings, return multiplication of the numbers as a string.N... 阅读全文
posted @ 2014-06-11 11:17 南郭子綦 阅读(4599) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/trapping-rain-water/题意:Givennnon-negative integers representing an elevation map where the width of each bar is ... 阅读全文
posted @ 2014-06-11 10:46 南郭子綦 阅读(4061) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/count-and-say/题意:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 11... 阅读全文
posted @ 2014-06-11 09:55 南郭子綦 阅读(4680) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/longest-valid-parentheses/题意:Given a string containing just the characters'('and')', find the length of the long... 阅读全文
posted @ 2014-06-10 16:59 南郭子綦 阅读(3421) 评论(1) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/next-permutation/题意:Implement next permutation, which rearranges numbers into the lexicographically next greater... 阅读全文
posted @ 2014-06-10 16:03 南郭子綦 阅读(5639) 评论(1) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/题意:You are given a string,S, and a list of words,L, that are all of th... 阅读全文
posted @ 2014-06-10 14:51 南郭子綦 阅读(3857) 评论(2) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/remove-element/题意:Given an array and a value, remove all instances of that value in place and return the new len... 阅读全文
posted @ 2014-06-10 13:59 南郭子綦 阅读(3974) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/题意:Given a sorted array, remove the duplicates in place such that each eleme... 阅读全文
posted @ 2014-06-10 13:38 南郭子綦 阅读(6318) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/generate-parentheses/题意:Givennpairs of parentheses, write a function to generate all combinations of well-formed... 阅读全文
posted @ 2014-06-10 13:25 南郭子綦 阅读(5315) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/valid-parentheses/题意:Given a string containing just the characters'(',')','{','}','['and']', determine if the in... 阅读全文
posted @ 2014-06-10 12:58 南郭子綦 阅读(5374) 评论(1) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/题意:Given a digit string, return all possible letter combinations that the ... 阅读全文
posted @ 2014-06-10 12:47 南郭子綦 阅读(5280) 评论(1) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/longest-common-prefix/题意:Write a function to find the longest common prefix string amongst an array of strings.解... 阅读全文
posted @ 2014-06-10 12:37 南郭子綦 阅读(3725) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/roman-to-integer/题意:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range f... 阅读全文
posted @ 2014-06-10 11:54 南郭子綦 阅读(5350) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/integer-to-roman/题意:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range f... 阅读全文
posted @ 2014-06-10 11:16 南郭子綦 阅读(4087) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/container-with-most-water/题意:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordina... 阅读全文
posted @ 2014-06-10 10:46 南郭子綦 阅读(3302) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/palindrome-number/题意:Determine whether an integer is a palindrome. Do this without extra space.click to show spo... 阅读全文
posted @ 2014-06-10 10:12 南郭子綦 阅读(4116) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/divide-two-integers/题意:Divide two integers without using multiplication, division and mod operator.解题思路:不许用乘、除和求... 阅读全文
posted @ 2014-06-10 09:55 南郭子綦 阅读(5130) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/string-to-integer-atoi/题意:Implementatoito convert a string to an integer.Hint:Carefully consider all possible in... 阅读全文
posted @ 2014-06-09 14:20 南郭子綦 阅读(6950) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/zigzag-conversion/题意:The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like thi... 阅读全文
posted @ 2014-06-09 13:42 南郭子綦 阅读(4297) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/reverse-integer/题意:Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321解题思路:翻... 阅读全文
posted @ 2014-06-09 13:35 南郭子綦 阅读(4802) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/longest-palindromic-substring/题意:Given a stringS, find the longest palindromic substring inS. You may assume tha... 阅读全文
posted @ 2014-06-09 13:25 南郭子綦 阅读(6932) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/combination-sum-ii/题意:Given a collection of candidate numbers (C) and a target number (T), find all unique combi... 阅读全文
posted @ 2014-06-09 11:48 南郭子綦 阅读(3583) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/combination-sum/题意:Given a set of candidate numbers (C) and a target number (T), find all unique combinations in... 阅读全文
posted @ 2014-06-09 11:32 南郭子綦 阅读(7940) 评论(6) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/first-missing-positive/题意:Given an unsorted integer array, find the first missing positive integer.For example,G... 阅读全文
posted @ 2014-06-09 11:20 南郭子綦 阅读(2876) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/search-in-rotated-sorted-array/题意:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e... 阅读全文
posted @ 2014-06-09 10:52 南郭子綦 阅读(3945) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/scramble-string/题意:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty su... 阅读全文
posted @ 2014-06-09 10:39 南郭子綦 阅读(2312) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/simplify-path/题意:Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home... 阅读全文
posted @ 2014-06-09 09:53 南郭子綦 阅读(2892) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/add-binary/题意:Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"... 阅读全文
posted @ 2014-06-08 11:45 南郭子綦 阅读(3942) 评论(2) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/search-for-a-range/题意:Given a sorted array of integers, find the starting and ending position of a given target ... 阅读全文
posted @ 2014-06-08 10:42 南郭子綦 阅读(3209) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/sqrtx/题意:Implementint sqrt(int x).Compute and return the square root ofx.解题思路:实现开平方函数。这里要注意的一点是返回的时一个整数。通过这一点我们可... 阅读全文
posted @ 2014-06-08 10:19 南郭子綦 阅读(4176) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/sort-colors/题意:Given an array withnobjects colored red, white or blue, sort them so that objects of the same col... 阅读全文
posted @ 2014-06-08 10:10 南郭子綦 阅读(4438) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/powx-n/题意:Implement pow(x,n).解题思路:求幂函数的实现。使用递归,类似于二分的思路,解法来自Mark Allen Weiss的《数据结构与算法分析》。正确代码:class Solution: ... 阅读全文
posted @ 2014-06-06 18:36 南郭子綦 阅读(4988) 评论(4) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/edit-distance/题意:Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2.... 阅读全文
posted @ 2014-06-06 18:07 南郭子綦 阅读(3917) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/rotate-image/题意:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Fo... 阅读全文
posted @ 2014-06-06 17:03 南郭子綦 阅读(4415) 评论(0) 推荐(1) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/length-of-last-word/题意:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', retu... 阅读全文
posted @ 2014-06-06 16:49 南郭子綦 阅读(2128) 评论(1) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/plus-one/题意:Given a non-negative number represented as an array of digits, plus one to the number.The digits are... 阅读全文
posted @ 2014-06-06 15:23 南郭子綦 阅读(3655) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/search-insert-position/题意:Given a sorted array and a target value, return the index if the target is found. If n... 阅读全文
posted @ 2014-06-06 15:14 南郭子綦 阅读(3717) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/merge-k-sorted-lists/题意:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its com... 阅读全文
posted @ 2014-06-06 12:18 南郭子綦 阅读(5568) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/sudoku-solver/题意:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated b... 阅读全文
posted @ 2014-06-05 14:26 南郭子綦 阅读(4021) 评论(3) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/valid-sudoku/题意:Determine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could b... 阅读全文
posted @ 2014-06-05 13:44 南郭子綦 阅读(4115) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/search-a-2d-matrix/题意:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the... 阅读全文
posted @ 2014-06-05 12:11 南郭子綦 阅读(2912) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/anagrams/题意:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be i... 阅读全文
posted @ 2014-06-05 11:39 南郭子綦 阅读(5014) 评论(3) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/spiral-matrix-ii/题意:Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.... 阅读全文
posted @ 2014-06-05 11:06 南郭子綦 阅读(2145) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/spiral-matrix/题意:Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral orde... 阅读全文
posted @ 2014-06-05 10:46 南郭子綦 阅读(4187) 评论(1) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/word-search/题意:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from... 阅读全文
posted @ 2014-06-05 10:23 南郭子綦 阅读(5498) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/merge-sorted-array/题意:Given two sorted integer arrays A and B, merge B into A as one sorted array.解题思路:归并排序的归并这一... 阅读全文
posted @ 2014-06-05 09:58 南郭子綦 阅读(4101) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/set-matrix-zeroes/题意:Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.解题... 阅读全文
posted @ 2014-06-05 09:53 南郭子綦 阅读(2779) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/restore-ip-addresses/题意:Given a string containing only digits, restore it by returning all possible valid IP add... 阅读全文
posted @ 2014-06-04 16:13 南郭子綦 阅读(3506) 评论(2) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/interleaving-string/题意:Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1... 阅读全文
posted @ 2014-06-04 12:56 南郭子綦 阅读(2498) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/distinct-subsequences/题意:Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subseq... 阅读全文
posted @ 2014-06-04 10:02 南郭子綦 阅读(2027) 评论(2) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/pascals-triangle-ii/题意:Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[... 阅读全文
posted @ 2014-06-03 20:06 南郭子綦 阅读(2064) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/pascals-triangle/题意:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Ret... 阅读全文
posted @ 2014-06-03 19:49 南郭子綦 阅读(2587) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/triangle/题意:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n... 阅读全文
posted @ 2014-06-03 19:36 南郭子綦 阅读(2873) 评论(0) 推荐(0) 编辑
摘要:算法导论上面快速排序的实现。代码:def partition(array, left, right): i = left-1 for j in range(left, right): if array[j] <= array[right]: i += ... 阅读全文
posted @ 2014-06-03 18:17 南郭子綦 阅读(1297) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/题意:Say you have an array for which theithelement is the price of a given sto... 阅读全文
posted @ 2014-06-03 17:24 南郭子綦 阅读(3563) 评论(1) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/题意:Say you have an array for which theithelement is the price of a given stoc... 阅读全文
posted @ 2014-06-03 16:15 南郭子綦 阅读(3552) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/题意:Say you have an array for which theithelement is the price of a given stock o... 阅读全文
posted @ 2014-06-03 15:59 南郭子綦 阅读(4929) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/valid-palindrome/题意:Given a string, determine if it is a palindrome, considering only alphanumeric characters an... 阅读全文
posted @ 2014-06-03 15:39 南郭子綦 阅读(3522) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/word-ladder/题意:Given two words (startandend), and a dictionary, find the length of shortest transformation seque... 阅读全文
posted @ 2014-06-03 15:28 南郭子綦 阅读(6409) 评论(2) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/longest-consecutive-sequence/题意:Given an unsorted array of integers, find the length of the longest consecutive ... 阅读全文
posted @ 2014-06-03 12:51 南郭子綦 阅读(3911) 评论(0) 推荐(0) 编辑
摘要:原题地址:https://oj.leetcode.com/problems/surrounded-regions/题意:Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is cap... 阅读全文
posted @ 2014-06-03 11:35 南郭子綦 阅读(4048) 评论(1) 推荐(0) 编辑

点击右上角即可分享
微信分享提示