摘要:
(Referrence: TutorialsPoint)Each of the collection classes provides an iterator( ) method that returns an iterator to the start of the collection. By ... 阅读全文
摘要:
QuestionGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in... 阅读全文
摘要:
QuestionSuppose 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).You are given a target... 阅读全文
摘要:
QuestionGiven an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the followi... 阅读全文
摘要:
QuestionGiven a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1,... 阅读全文
摘要:
这两个系列的题目其实是同一套题,可以互相转换。首先我们定义一个数组: prefixSum (前序和数组)Given nums: [1, 2, -2, 3]prefixSum: [0, 1, 3, 1, 4 ]现在我们发现对prefixSum做Best Time To Buy And Sell S... 阅读全文
摘要:
QuestionGiven a collection of integers that might contain duplicates,nums, return all possible subsets.Note:Elements in a subset must be in non-descen... 阅读全文
摘要:
QuestionGiven an array S ofnintegers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three int... 阅读全文
摘要:
QuestionGiven an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Not... 阅读全文
摘要:
QuestionA peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return it... 阅读全文