- 博客(43)
- 收藏
- 关注
原创 152. Maximum Product Subarray
Problem Description:Given an integer arraynums, find the contiguous subarray within an array (containing at least one number) which has the largest product.Example 1:Input: [2,3,-2,4]Output:...
2019-10-30 19:29:26 75
原创 123. Best Time to Buy and Sell Stock III
Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at mosttwotransaction...
2019-10-24 17:20:59 66
原创 122. Best Time to Buy and Sell Stock II
Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as...
2019-10-24 12:41:23 85
原创 122. Best Time to Buy and Sell Stock II
Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as...
2019-10-24 12:31:44 93
原创 121. Best Time to Buy and Sell Stock
Problem Description: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 (i.e., buy one and sell o...
2019-10-23 16:32:29 69
原创 120. Triangle
Problem Description: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[ ...
2019-10-23 16:19:27 213
原创 119. Pascal's Triangle II
Problem Description:Given a non-negativeindexkwherek≤33, return thekthindex row of the Pascal's triangle.Note that the row index starts from0.In Pascal's triangle, each number is the ...
2019-10-23 16:04:05 111
原创 118. Pascal's Triangle
Problem Description:Given a non-negative integernumRows, generate the firstnumRowsof Pascal's triangle.In Pascal's triangle, each number is the sum of the two numbers directly above it.Exam...
2019-10-23 15:41:16 75
原创 106. Construct Binary Tree from Inorder and Postorder Traversal
Problem Description:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, giveninorder =[9,3,...
2019-10-23 15:13:08 87
原创 105. Construct Binary Tree from Preorder and Inorder Traversal
Problem Description:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, givenpreorder =[3,9,...
2019-10-23 12:44:28 128
原创 90. Subsets II
Problem Description:Given a collection of integers that might contain duplicates,nums, return all possible subsets (the power set).Note:The solution set must not contain duplicate subsets.Exa...
2019-10-22 15:41:38 73
原创 88. Merge Sorted Array
Problem Description:Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:The number of elements initialized innums1andnums2aremandnrespective...
2019-10-22 15:17:30 100
原创 85. Maximal Rectangle
Problem Description:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.Example:Input:[ ["1","0","1","0","0"], ["1","0","1...
2019-10-22 15:04:44 61
原创 84. Largest Rectangle in Histogram
Problem Description:Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a his...
2019-10-22 12:58:05 77
原创 81. Search in Rotated Sorted Array II
Problem Description:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e.,[0,0,1,2,2,5,6]might become[2,5,6,0,0,1,2]).You are given a target val...
2019-10-21 17:20:16 60
原创 80. Remove Duplicates from Sorted Array II
Problem Description:Given a sorted arraynums, remove the duplicatesin-placesuch that duplicates appeared at mosttwiceand return the new length.Do not allocate extra space for another array, ...
2019-10-21 16:52:24 54
原创 79. Word Search
Problem Description:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horiz...
2019-10-21 15:52:07 63
原创 78. Subsets
Problem Description:Given a set ofdistinctintegers,nums, return all possible subsets (the power set).Note:The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3...
2019-10-21 12:45:36 58
原创 75. Sort Colors
Problem Description:Given an array withnobjects colored red, white or blue, sort themin-placeso that objects of the same color are adjacent, with the colors in the order red, white and blue.H...
2019-10-21 12:08:00 64
原创 74. Search a 2D Matrix
Problem Description:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right. The fi...
2019-10-21 11:16:37 64
原创 73. Set Matrix Zeroes
Problem Description:Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do itin-place.Example 1:Input: [ [1,1,1], [1,0,1], [1,1,1]]Output: [ [1,0,1], [...
2019-10-18 17:01:52 173
原创 66. Plus One
Problem Description:Given anon-emptyarray of digitsrepresenting a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the...
2019-10-18 16:09:39 1289
原创 64. Minimum Path Sum
Problem Description: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:You can only move ei...
2019-10-18 13:33:18 72
原创 63. Unique Paths II
Problem Description: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 point in time. The robot is...
2019-10-17 16:46:07 89
原创 62. Unique Paths
Problem Description: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 point in time. The robot is...
2019-10-17 15:42:42 73
原创 59. Spiral Matrix II
Problem Description:Given a positive integern, generate a square matrix filled with elements from 1 ton2in spiral order.Example:Input: 3Output:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ]]...
2019-10-17 15:16:42 78
原创 57. Insert Interval
Problem Description:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to th...
2019-10-16 15:40:11 108
原创 56. Merge Intervals
Problem Description:Given a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [...
2019-10-16 15:00:21 113
原创 55. Jump Game
Problem Description: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 pos...
2019-10-15 12:42:22 128
原创 54. Spiral Matrix
Problem Description:Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.Example 1:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Output...
2019-10-15 11:55:18 72
原创 53. Maximum Subarray
Problem Description:Given an integer arraynums, find the contiguous subarray(containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4...
2019-10-14 14:12:24 83
原创 48. Rotate Image
Problem Description:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the imagein-place, which means you have to modif...
2019-10-14 12:37:34 64
原创 45. Jump Game II
Problem Description: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 pos...
2019-10-12 18:38:59 94
原创 42. Trapping Rain Water
Problem Description: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.The above elevation map ...
2019-10-12 16:48:30 57
转载 最流行的4个机器学习数据集
机器学习算法需要作用于数据,而数据的本质则决定了应用的机器学习算法是否合适,而数据的质量也会决定算法表现的好坏程度。所以会研究数据,会分析数据很重要。本文作为学习研究数据系列博文的开篇,列举了4个最流行的机器学习数据集。IrisIris也称鸢尾花卉数据集,是一类多重变量分析的数据集。通过花萼长度,花萼宽度,花瓣长度,花瓣宽度4个属性预测鸢尾花卉属于(Setosa,Versicolour,V...
2019-10-11 15:05:46 185
原创 41. First Missing Positive
Problem Description:Given an unsorted integer array, find the smallest missingpositive integer.Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,4,-1,1]Output: 2Example 3:Inp...
2019-10-11 14:53:18 54
原创 34. Find First and Last Position of Element in Sorted Array
Problem Description:Given an array of integersnumssorted in ascending order, find the starting and ending position of a giventargetvalue.Your algorithm's runtime complexity must be in the ord...
2019-10-11 14:34:15 73
原创 33. Search in Rotated Sorted Array
Problem Description:Suppose an array sorted in ascending order 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 va...
2019-10-10 19:35:53 58
转载 Python-modules-packages
列表推导式# 循环可以用来生成列表values = [10, 21, 4, 7, 12]squares = []for x in values: squares.append(x**2)print squares# 列表推导式可以使用更简单的方法来创建这个列表values = [10, 21, 4, 7, 12]squares = [x**2 for x in va...
2019-10-10 18:06:28 115
转载 Python 字典
字典字典Dictionary,在一些变成语言中也称为hash, map, 是一种由键值对组成的数据结构。顾名思义,我们把键值想象成字典中的单词,值想象成词对应的定义,那么——一个词可以对应一个或者多个定义,但是这些定义只能通过这个词来进行查询。基本操作空字典Python使用{}或者dict{}来创建一个个空的字典:a = {}type{a}a = ...
2019-10-10 15:58:19 678
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人