摘要:
参考 : https://www.jianshu.com/p/bb82dca89e2d Divide-and-conquer merge sort 的核心理念是 Divide-and-conquer ,这个范式的核心是把问题分割成跟原问题相似的子问题,然后,递归的解决这些子问题,最后把这些子问题的结 阅读全文
摘要:
题意: Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j]. 这种不能破坏 i 和j “相对关系” 的情况去统计一些结果的题,都可以考虑merge sort. m 阅读全文
摘要:
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 阅读全文
摘要:
这题 和 327. Count of Range Sum and 493. Reverse Pairs 几乎一样的解法,都属于hard 题, 可以用 merge sort, segment tree 和 BST 去求解。 注意如果自己去实现简单的BST, 在数组已经排序好的情况下 比 [1 2 3 阅读全文