MCPcopy Create free account
hub / github.com/ShahjalalShohag/code-library / sum

Method sum

Data Structures/Wavelet Tree.cpp:73–78  ·  view source on GitHub ↗

sum of numbers in [l ,r] less than or equal to k

Source from the content-addressed store, hash-verified

71 }
72 //sum of numbers in [l ,r] less than or equal to k
73 int sum(int l, int r, int k) {
74 if(l > r or k < lo) return 0;
75 if(hi <= k) return c[r] - c[l - 1];
76 int lb = b[l - 1], rb = b[r];
77 return this->l->sum(lb + 1, rb, k) + this->r->sum(l - lb, r - rb, k);
78 }
79 ~wavelet_tree() {
80 delete l;
81 delete r;

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected