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

Function update_segtree

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

Source from the content-addressed store, hash-verified

123}
124
125void update_segtree(ll curr,ll l,ll r,ll pos,ll new_val,vl &segtree){
126 if(l==r){
127 segtree[curr]=new_val;
128 }
129 else{
130 ll mid=(l+r)/2;
131 if(pos<=mid){
132 update_segtree(2*curr,l,mid,pos,new_val,segtree);
133 }
134 else{
135 update_segtree(2*curr+1,mid+1,r,pos,new_val,segtree);
136 }
137 segtree[curr]=segtree[2*curr]+segtree[2*curr+1];
138 }
139}
140
141void solve(){
142 ll n;

Callers 1

solveFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected