摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:Sqrt(x)Implementint sqrt(int x).Compute and return the square root ofx.【注意】:1.本题int类型可能会溢出,因此不能用乘法运算,应尽量用除法。2. 绝大多数数字都不是可开方的,该如何得到比较近的结果呢?算法思路:思路1:顺序遍...
阅读全文
摘要:Single Number IIGiven an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a lin...
阅读全文
摘要: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...
阅读全文
摘要:Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4...
阅读全文
摘要:排序算法是算法中的基础,也是面试常问常考的算法之一,今天先简单整理一下最常考的三个排序算法。以后有空(希望有空)了再统一优化一下。七大排序算法的复杂度分析排序算法最坏时间辅助度平均时间复杂度空间复杂度稳定性备注冒泡排序 O(n^2) O(n^2) O(1)YES交换排序 O(n^2) O(...
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:CandyThere areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following ...
阅读全文
摘要: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]...
阅读全文
摘要: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...
阅读全文
摘要:Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangemen...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:Pascal's TriangleGivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,...
阅读全文
摘要:Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =...
阅读全文
摘要:Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new lengt...
阅读全文
摘要: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. ...
阅读全文