2022-05-07:返回一个数组中,所有降序三元组的数量。...比如 : {5, 3, 4, 2, 1},
所有降序三元组为 :
{5, 3, 2}、{5, 3, 1}、{5, 4, 2}、{5, 4, 1}、
{5, 2, 1}、{3, 2, 1}、{4, 2,...所以返回数量7。
答案2022-05-07:
利用index tree。
时间复杂度:O(N * logN)。
空间复杂度:O(N)。
代码用rust编写。...struct IndexTree {
pub tree: Vec,
pub n: isize,
}
// 下标从1开始
impl IndexTree {
// 0位置弃而不用