01 2015 档案

leetcode 【 Best Time to Buy and Sell Stock 】python 实现
摘要:思路:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction ... 阅读全文

posted @ 2015-01-31 21:34 承续缘 阅读(257) 评论(0) 推荐(0) 编辑

leetcode 【 Container With Most Water 】python 实现
摘要:题目:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints ... 阅读全文

posted @ 2015-01-31 20:36 承续缘 阅读(168) 评论(0) 推荐(0) 编辑

leetcode 【 Find Minimum in Rotated Sorted Array II 】python 实现
摘要:题目:Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a s... 阅读全文

posted @ 2015-01-31 14:37 承续缘 阅读(190) 评论(0) 推荐(0) 编辑

leetcode 【 Minimum Path Sum 】python 实现
摘要:题目:Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note... 阅读全文

posted @ 2015-01-31 00:30 承续缘 阅读(155) 评论(0) 推荐(0) 编辑

leetcode 【 Find Minimum in Rotated Sorted Array 】python 实现
摘要:题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.Yo... 阅读全文

posted @ 2015-01-30 00:01 承续缘 阅读(199) 评论(0) 推荐(0) 编辑

leetcode 【 Search for a Range 】python 实现
摘要:题目: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 ... 阅读全文

posted @ 2015-01-29 23:39 承续缘 阅读(154) 评论(0) 推荐(0) 编辑

leetcode 【Search a 2D Matrix 】python 实现
摘要:题目:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted fro... 阅读全文

posted @ 2015-01-29 23:02 承续缘 阅读(292) 评论(0) 推荐(0) 编辑

leetcode 【 Search in Rotated Sorted Array II 】python 实现
摘要:题目:与上一道题几乎相同;不同之处在于array中允许有重复元素;但题目要求也简单了,只要返回true or falsehttp://www.cnblogs.com/xbf9xbf/p/4254590.html代码:oj测试通过Runtime:73 ms 1 class Solution: 2 ... 阅读全文

posted @ 2015-01-28 00:07 承续缘 阅读(154) 评论(0) 推荐(0) 编辑

leetcode 【 Search in Rotated Sorted Array 】python 实现
摘要:题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target valu... 阅读全文

posted @ 2015-01-27 22:41 承续缘 阅读(452) 评论(0) 推荐(0) 编辑

leetcode 【 Subsets II 】python 实现
摘要:题目:Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending ord... 阅读全文

posted @ 2015-01-27 19:48 承续缘 阅读(234) 评论(0) 推荐(0) 编辑

leetcode 【 Subsets 】python 实现
摘要:题目:Given a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not... 阅读全文

posted @ 2015-01-27 15:55 承续缘 阅读(1165) 评论(0) 推荐(0) 编辑

leetcode 【 Trapping Rain Water 】python 实现
摘要:题目:Givennnon-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... 阅读全文

posted @ 2015-01-26 22:34 承续缘 阅读(313) 评论(0) 推荐(0) 编辑

leetcode 【 Triangle 】python 实现
摘要:题目: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 ... 阅读全文

posted @ 2015-01-26 19:55 承续缘 阅读(268) 评论(0) 推荐(0) 编辑

leetcode 【 Two Sum 】python 实现
摘要:题目:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two... 阅读全文

posted @ 2015-01-26 17:55 承续缘 阅读(160) 评论(0) 推荐(0) 编辑

leetcode 【 Unique Paths II 】 python 实现
摘要:题目: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 spac... 阅读全文

posted @ 2015-01-26 16:12 承续缘 阅读(235) 评论(0) 推荐(0) 编辑

leetcode 【 Unique Paths 】python 实现
摘要:题目:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any poi... 阅读全文

posted @ 2015-01-26 14:59 承续缘 阅读(716) 评论(0) 推荐(0) 编辑

leetcode 【 Set Matrix Zeroes 】python 实现
摘要:题目:Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?... 阅读全文

posted @ 2015-01-24 20:05 承续缘 阅读(267) 评论(0) 推荐(0) 编辑

leetcode 【 Sort Colors 】python 实现
摘要:题目:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red,... 阅读全文

posted @ 2015-01-24 18:55 承续缘 阅读(243) 评论(0) 推荐(0) 编辑

leetcode 【 Search Insert Position 】python 实现
摘要:题目: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... 阅读全文

posted @ 2015-01-24 12:24 承续缘 阅读(212) 评论(0) 推荐(0) 编辑

leetcode 【 Find Peak Element 】python 实现
摘要:题目:A peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return its ind... 阅读全文

posted @ 2015-01-22 23:10 承续缘 阅读(883) 评论(0) 推荐(0) 编辑

leetcode 【 Majority Element 】python 实现
摘要:题目:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the ... 阅读全文

posted @ 2015-01-22 14:41 承续缘 阅读(350) 评论(0) 推荐(0) 编辑

leetcode 【 Maximum Subarray 】python 实现
摘要:题目: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... 阅读全文

posted @ 2015-01-22 00:12 承续缘 阅读(1335) 评论(1) 推荐(1) 编辑

leetcode 【 Merge Sorted Array 】python 实现
摘要:题目:Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or eq... 阅读全文

posted @ 2015-01-21 22:04 承续缘 阅读(837) 评论(0) 推荐(0) 编辑

leetcode 【 Rotate Image 】python 实现
摘要:题目:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?代码:oj测试通过Runtime... 阅读全文

posted @ 2015-01-18 23:10 承续缘 阅读(287) 评论(0) 推荐(0) 编辑

leetcode 【 Pascal's Triangle II 】python 实现
摘要:题目:Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onl... 阅读全文

posted @ 2015-01-18 21:22 承续缘 阅读(325) 评论(0) 推荐(0) 编辑

leetcode 【 Pascal's Triangle 】python 实现
摘要:题目:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4... 阅读全文

posted @ 2015-01-16 23:15 承续缘 阅读(349) 评论(0) 推荐(0) 编辑

leetcode 【 Plus One 】python 实现
摘要:题目: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... 阅读全文

posted @ 2015-01-16 22:39 承续缘 阅读(301) 评论(0) 推荐(0) 编辑

leetcode 【 Remove Duplicates from Sorted Array II 】python 实现
摘要:题目:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ... 阅读全文

posted @ 2015-01-16 22:08 承续缘 阅读(211) 评论(0) 推荐(0) 编辑

leetcode 【 Remove Duplicates from Sorted Array 】python 实现
摘要:题目:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space fo... 阅读全文

posted @ 2015-01-16 21:31 承续缘 阅读(198) 评论(0) 推荐(0) 编辑

leetcode 【 Remove Element 】python 实现
摘要:题目:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't ... 阅读全文

posted @ 2015-01-16 20:58 承续缘 阅读(395) 评论(0) 推荐(0) 编辑

leetcode 【 Add Two Numbers 】 python 实现
摘要:题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a sing... 阅读全文

posted @ 2015-01-16 13:10 承续缘 阅读(226) 评论(0) 推荐(0) 编辑

leetcode 【 Convert Sorted List to Binary Search Tree 】python 实现
摘要:题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.代码:oj测试通过Runtime:178 ms 1 # Definition... 阅读全文

posted @ 2015-01-11 20:06 承续缘 阅读(419) 评论(0) 推荐(0) 编辑

leetcode 【 Copy List with Random Pointer 】 python 实现
摘要:题目: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 co... 阅读全文

posted @ 2015-01-11 16:13 承续缘 阅读(481) 评论(0) 推荐(0) 编辑

leetcode 【 Merge k Sorted Lists 】python 实现
摘要:题目:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.代码:oj测试通过Runtime:231 ms 1 # Definition for singly-l... 阅读全文

posted @ 2015-01-10 13:57 承续缘 阅读(1036) 评论(0) 推荐(0) 编辑

leetcode 【 Partition List 】python 实现
摘要:题目:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the or... 阅读全文

posted @ 2015-01-10 11:06 承续缘 阅读(251) 评论(0) 推荐(0) 编辑

leetcode 【 Swap Nodes in Pairs 】python 实现
摘要:题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your al... 阅读全文

posted @ 2015-01-09 23:49 承续缘 阅读(249) 评论(0) 推荐(0) 编辑

leetcode 【 Reorder List 】python 实现
摘要:题目:Given a singly linked listL: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 e... 阅读全文

posted @ 2015-01-09 23:19 承续缘 阅读(275) 评论(1) 推荐(0) 编辑

leetcode 【 Reverse Nodes in k-Group 】 python 实现
摘要:原题:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen lef... 阅读全文

posted @ 2015-01-09 11:22 承续缘 阅读(229) 评论(0) 推荐(0) 编辑

leetcode 【 Reverse Linked List II 】 python 实现
摘要:题目:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL... 阅读全文

posted @ 2015-01-08 23:44 承续缘 阅读(1118) 评论(0) 推荐(0) 编辑

leetcode 【 Sort List 】 python 实现
摘要:题目:Sort a linked list inO(nlogn) time using constant space complexity.代码:oj 测试通过Runtime:372 ms 1 # Definition for singly-linked list. 2 # class ListNo... 阅读全文

posted @ 2015-01-08 17:28 承续缘 阅读(379) 评论(0) 推荐(0) 编辑

leetcode 【 Insertion Sort List 】 python 实现
摘要:题目:Sort a linked list using insertion sort.代码:oj测试通过Runtime:860 ms 1 # Definition for singly-linked list. 2 # class ListNode: 3 # def __init__(sel... 阅读全文

posted @ 2015-01-03 19:54 承续缘 阅读(369) 评论(0) 推荐(0) 编辑

leetcode 【 Linked List Cycle II 】 python 实现
摘要:公司和学校事情比较多,隔了好几天没刷题,今天继续刷起来。题目:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve i... 阅读全文

posted @ 2015-01-03 15:58 承续缘 阅读(307) 评论(0) 推荐(0) 编辑

导航