分类:全部列表
[LeetCode]57.InsertInterval插入区间Givenasetof non-overlapping intervals,insertanewintervalintotheintervals(mergeifnecessary).Youmayassumethattheintervalswereinitiallysortedaccordingtotheirstarttimes.Example1:Input:intervals=[[1,3],[6,9]],newInterval=[2,5]Output:[[1,5],[6,9]]Example2:Input:intervals=[[1,2],[3,5],[6,7],[8,10],[12,16]],newInterval...
继续阅读 >
[LeetCode]56.MergeIntervals合并区间Givenacollectionofintervals,mergealloverlappingintervals.Example1:Input:[[1,3],[2,6],[8,10],[15,18]]Output:[[1,6],[8,10],[15,18]]Explanation:Sinceintervals[1,3]and[2,6]overlaps,mergetheminto[1,6].Example2:Input:[[1,4],[4,5]]Output:[[1,5]]Explanation:Intervals[1,4]and[4,5]areconsideredoverlapping.NOTE: inputtypeshavebeen...
继续阅读 >
[LeetCode]53.MaximumSubarray最大子数组Givenanintegerarray nums,findthecontiguoussubarray (containingatleastonenumber)whichhasthelargestsumandreturnitssum.Example:Input:[-2,1,-3,4,-1,2,1,-5,4],Output:6Explanation: [4,-1,2,1]hasthelargestsum=6.Followup:IfyouhavefiguredouttheO(n)solution,trycodinganothersolutionusingthedivideandconquera...
继续阅读 >