摘要:
Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Range sum S(i, j) is defined as the sum of the eleme 阅读全文
摘要:
假设我们已经知道数组左右两部分的逆序数对(记为inv1和inv2),我们在merge的过程中除了inv1+inv2之外,还需要计算merge过程总的逆序数对。 如何计算merge()? 在归并过程中,让i作为左边数组的遍历索引,j作为右边数组的遍历索引。在合并的过程中,如果a[i]>b[j],那么合 阅读全文
摘要:
You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smal 阅读全文
摘要:
Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be for 阅读全文