文章分类 - 树状数组
摘要:class Solution { public int countRangeSum(int[] nums, int lower, int upper) { int n = nums.length; // 前缀数组 long[] f = new long[n + 1]; // 离散化 // TreeS
阅读全文
摘要:class NumArray { int[] tr; int[] nums; int n; private int lowbit(int x) { return x & -x; } private void add(int x, int v) { for (int i = x; i <= n; i
阅读全文
摘要:class Solution { int[] tr; int n; private int lowbit(int x) { return x & -x; } private void add(int x, int v) { for (int i = x; i <= n; i += lowbit(i)
阅读全文