Subsequence Problem is one of themost common algorithm problem, which is not easy to figure out. First of all, the subsequence problem itself is more difficult than those for substring and subarray, since the former needs to deal with discontinuous sequence, while the latter two are continuous....
You may assume thatnums1has enough space (size that is equal tom+n) to hold additional elements fromnums2. 合并两个排序数组,把第二个合并到第一个里面,保证第一个长度是够的。 用3个指针搞定,第一个指针=n+m-1,是从后往前指向nums1的,用来插入nums1或者nums2的数,第二个指针=m-1是从后往前指...
In a given integer arraynums, there is always exactly one largest element. Find whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, otherwise return -1. 给一个数组,求最大值,如果最大...