| 45 | } |
| 46 | |
| 47 | void update(vector<int> &tree, int si, int ei, int idx, int index, int val) |
| 48 | { |
| 49 | if (si > index || ei < index) |
| 50 | { |
| 51 | return; |
| 52 | } |
| 53 | tree[idx] += val; |
| 54 | if (si < ei) |
| 55 | { |
| 56 | int mid = si + ((ei - si) / 2); |
| 57 | update(tree, si, mid, (2 * idx) + 1, index, val); |
| 58 | update(tree, mid + 1, ei, (2 * idx) + 2, index, val); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | void update(vector<int> &nums, vector<int> &tree, int index, int val) |
| 63 | { |