随笔分类 -  array

上一页 1 2

[leetcode]Jump Game II
摘要:Jump Game IIGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents... 阅读全文

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

[leetcode]Jump Game
摘要:Jump GameGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents yo... 阅读全文

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

[leetcode]Sqrt(x)
摘要:Sqrt(x)Implementint sqrt(int x).Compute and return the square root ofx.【注意】:1.本题int类型可能会溢出,因此不能用乘法运算,应尽量用除法。2. 绝大多数数字都不是可开方的,该如何得到比较近的结果呢?算法思路:思路1:顺序遍... 阅读全文

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

[leetcode]Single Number II
摘要:Single Number IIGiven an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a lin... 阅读全文

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

[leetcode]Surrounded Regions
摘要:Surrounded RegionsGiven a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that... 阅读全文

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

[leetcode]Longest Consecutive Sequence
摘要:Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4... 阅读全文

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

排序算法(初级版)之快排、归并、堆排序
摘要:排序算法是算法中的基础,也是面试常问常考的算法之一,今天先简单整理一下最常考的三个排序算法。以后有空(希望有空)了再统一优化一下。七大排序算法的复杂度分析排序算法最坏时间辅助度平均时间复杂度空间复杂度稳定性备注冒泡排序 O(n^2) O(n^2) O(1)YES交换排序 O(n^2) O(... 阅读全文

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

[leetcode]Best Time to Buy and Sell Stock II
摘要:Best Time to Buy and Sell Stock IISay 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-06 22:58 喵星人与汪星人 阅读(201) 评论(0) 推荐(0)

[leetcode]Best Time to Buy and Sell Stock
摘要:Best Time to Buy and Sell StockSay you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to compl... 阅读全文

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

[leetcode]Gas Station
摘要:Gas StationThere areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it... 阅读全文

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

[leetcode]Candy
摘要:CandyThere areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following ... 阅读全文

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

[leetcode]Merge Intervals
摘要:Merge IntervalsGiven 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]... 阅读全文

posted @ 2014-07-25 20:56 喵星人与汪星人 阅读(199) 评论(0) 推荐(0)

[leetcode]Merge Sorted Array
摘要:Merge Sorted ArrayGiven 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 i... 阅读全文

posted @ 2014-07-24 22:52 喵星人与汪星人 阅读(229) 评论(0) 推荐(0)

[leetcode]Next Permutation
摘要:Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangemen... 阅读全文

posted @ 2014-07-23 18:41 喵星人与汪星人 阅读(264) 评论(0) 推荐(0)

[leetcode]Triangle
摘要:TriangleGiven 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... 阅读全文

posted @ 2014-07-22 01:41 喵星人与汪星人 阅读(311) 评论(0) 推荐(0)

[leetcode]Pascal's Triangle II
摘要:Pascal's Triangle IIGiven an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your alg... 阅读全文

posted @ 2014-07-22 01:01 喵星人与汪星人 阅读(257) 评论(0) 推荐(0)

[leetcode]Pascal's Triangle
摘要:Pascal's TriangleGivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,... 阅读全文

posted @ 2014-07-22 00:35 喵星人与汪星人 阅读(419) 评论(0) 推荐(0)

[leetcode]Remove Duplicates from Sorted Array II
摘要:Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =... 阅读全文

posted @ 2014-07-21 23:55 喵星人与汪星人 阅读(246) 评论(0) 推荐(0)

[leetcode]Remove Duplicates from Sorted Array
摘要:Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new lengt... 阅读全文

posted @ 2014-07-21 23:35 喵星人与汪星人 阅读(274) 评论(0) 推荐(0)

[leetcode]Remove Element
摘要:Remove ElementGiven 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. ... 阅读全文

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

上一页 1 2