随笔分类 -  array

1 2 下一页

[leecode]Best Time to Buy and Sell Stock III
摘要:Best Time to Buy and Sell Stock IIISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the... 阅读全文

posted @ 2014-08-26 17:20 喵星人与汪星人 阅读(194) 评论(0) 推荐(0)

快速排序之单项扫描法
摘要:快速排序是排序算法中最受青睐的算法之一,相对于堆排序和归并排序而言,即便具有相同的复杂度O(NlogN)。面对大数据而言,快排的效率也更高。一般而言,数据结构中的排序算法都是采取的双向指针法。在之前写的一篇博文《排序算法(初级版)之快排、归并、堆排序》中已经有过总结。这里就不再啰嗦了。本篇博文主要讲... 阅读全文

posted @ 2014-08-22 17:00 喵星人与汪星人 阅读(1818) 评论(0) 推荐(0)

[leetcode]Minimum Path Sum
摘要:Minimum Path SumGiven amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along ... 阅读全文

posted @ 2014-08-16 00:58 喵星人与汪星人 阅读(204) 评论(0) 推荐(0)

[leetcode]Spiral Matrix
摘要:Spiral MatrixGiven a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[... 阅读全文

posted @ 2014-08-15 15:55 喵星人与汪星人 阅读(214) 评论(0) 推荐(0)

[leetcode]Spiral Matrix II
摘要:Spiral Matrix IIGiven an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the... 阅读全文

posted @ 2014-08-15 14:54 喵星人与汪星人 阅读(294) 评论(0) 推荐(0)

[leetcode]Rotate Image
摘要:Rotate ImageYou are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?CC上的原题,... 阅读全文

posted @ 2014-08-14 01:08 喵星人与汪星人 阅读(226) 评论(0) 推荐(0)

[leetcode]Sort Colors
摘要:Sort ColorsGiven an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the or... 阅读全文

posted @ 2014-08-11 21:48 喵星人与汪星人 阅读(260) 评论(0) 推荐(0)

[leetcode]Search a 2D Matrix
摘要:Search a 2D MatrixWrite an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row... 阅读全文

posted @ 2014-08-11 20:07 喵星人与汪星人 阅读(135) 评论(0) 推荐(0)

[leetcode]Maximum Subarray
摘要:Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−... 阅读全文

posted @ 2014-08-10 19:47 喵星人与汪星人 阅读(208) 评论(0) 推荐(0)

[leetcode]First Missing Positive
摘要:First Missing PositiveGiven an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Yo... 阅读全文

posted @ 2014-08-09 22:32 喵星人与汪星人 阅读(172) 评论(0) 推荐(0)

[leetcode]Sudoku Solver
摘要:Sudoku SolverWrite a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that the... 阅读全文

posted @ 2014-08-09 21:17 喵星人与汪星人 阅读(218) 评论(0) 推荐(0)

[leetcode]Valid Sudoku
摘要:Valid SudokuDetermine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are ... 阅读全文

posted @ 2014-08-09 20:38 喵星人与汪星人 阅读(285) 评论(0) 推荐(0)

[leetcode]Search in Rotated Sorted Array
摘要:Search in Rotated Sorted ArraySuppose 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).... 阅读全文

posted @ 2014-08-09 16:57 喵星人与汪星人 阅读(271) 评论(0) 推荐(0)

[leetcode]Search for a Range
摘要:Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity ... 阅读全文

posted @ 2014-08-09 16:10 喵星人与汪星人 阅读(276) 评论(0) 推荐(0)

[leetcode]Search Insert Position
摘要:Search Insert PositionGiven 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 ... 阅读全文

posted @ 2014-08-09 15:47 喵星人与汪星人 阅读(231) 评论(0) 推荐(0)

[leetcode]Unique Paths II
摘要:Unique Paths IIFollow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle an... 阅读全文

posted @ 2014-08-08 22:43 喵星人与汪星人 阅读(196) 评论(0) 推荐(0)

[leetcode]Unique Paths
摘要:Unique PathsA 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 a... 阅读全文

posted @ 2014-08-08 22:23 喵星人与汪星人 阅读(230) 评论(0) 推荐(0)

[leetcode]Median of Two Sorted Arrays
摘要:Median of Two Sorted ArraysThere are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run... 阅读全文

posted @ 2014-08-08 15:13 喵星人与汪星人 阅读(239) 评论(0) 推荐(0)

[leetcode]Container With Most Water
摘要:Container With Most WaterGivennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such t... 阅读全文

posted @ 2014-08-08 11:21 喵星人与汪星人 阅读(187) 评论(0) 推荐(0)

[leetcode]Trapping Rain Water
摘要:Trapping Rain WaterGivennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to tr... 阅读全文

posted @ 2014-08-08 11:07 喵星人与汪星人 阅读(152) 评论(0) 推荐(0)

1 2 下一页