分类:全部列表
[LeetCode]35.SearchInsertPosition搜索插入位置Givenasortedarrayandatargetvalue,returntheindexifthetargetisfound.Ifnot,returntheindexwhereitwouldbeifitwereinsertedinorder.Youmayassumenoduplicatesinthearray.Example1:Input:[1,3,5,6],5Output:2Example2:Input:[1,3,5,6],2Output:1Example3:Input:[1,3,5,6],7Output:4Example4:Input:[1,3,5,6],0Output:0这...
继续阅读 >
[LeetCode]33.SearchinRotatedSortedArray在旋转有序数组中搜索Supposeanarraysortedinascendingorderisrotatedatsomepivotunknowntoyoubeforehand.(i.e., [0,1,2,4,5,6,7] mightbecome [4,5,6,7,0,1,2]).Youaregivenatargetvaluetosearch.Iffoundinthearrayreturnitsindex,otherwisereturn -1.Youmayassumenoduplicateexistsinthearray.Youralgorithm'sru...
继续阅读 >