MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / sum_segtree

Function sum_segtree

CPP/Segment Tree/Sum query.cpp:112–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112ll sum_segtree(ll curr,ll curr_l,ll curr_r,ll l,ll r,vl &segtree){
113 if(l>r){
114 return 0;
115 }
116
117 if(l==curr_l and r==curr_r){
118 return segtree[curr];
119 }
120
121 ll mid=(curr_l+curr_r)/2;
122 return sum_segtree(2*curr,curr_l,mid,l,min(r,mid),segtree)+sum_segtree(2*curr+1,mid+1,curr_r,max(l,mid+1),r,segtree);
123}
124
125void update_segtree(ll curr,ll l,ll r,ll pos,ll new_val,vl &segtree){
126 if(l==r){

Callers 1

solveFunction · 0.85

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected