树状数组
我,秦始皇的爷爷,打钱
道阻且长,行则将至
展开
-
LeetCode刷题记185-Binary Indexed Tree(树状数组)
327. 区间和的个数 class Solution { int[] a; public void init(int n) { a = new int[n + 1]; } public void insert(int i, int x) { while (i < a.length) { a[i] += x; i += lowbit(i); } } pub原创 2021-02-28 15:38:21 · 83 阅读 · 0 评论 -
LeetCode刷题记161-315. 计算右侧小于当前元素的个数【再做一遍】
LeetCode刷题记161 315. 计算右侧小于当前元素的个数 题目原创 2020-12-26 16:07:34 · 70 阅读 · 0 评论 -
LeetCode刷题记178-307. 区域和检索 - 数组可修改
LeetCode刷题记178 307. 区域和检索 - 数组可修改 题目 class NumArray { int[] _nums; int[] sum; public int lowbit(int x) { return x & (-x); } public NumArray(int[] nums) { _nums = new int[nums.length + 1]; sum = new int[num原创 2021-01-18 14:20:09 · 90 阅读 · 0 评论