void updateLazy(int node, int start, int end, int L, int R){

if(lazy[node] == 1){ //i.e update curr node if lazy has been set previously

ST[node] = (end-start+1) - ST[node];

if(start != end){ //i.e if not a leaf then mark children

lazy[node<<1] = 1-lazy[node<<1];

lazy[(node<<1)+1] = 1-lazy[(node<<1)+1];

}

lazy[node] = 0;

}

if(L > end || R < start) return; // THIS LINE

if(start >= L && end <= R){ //segment inside range hence update

ST[node] = (end-start+1) - ST[node];

if(start != end){ //i.e if no leaf then mark children

lazy[node<<1] = 1-lazy[node<<1];

lazy[(node<<1)+1] = 1-lazy[(node<<1)+1];

}

return; //we donot go down the tree and update every node

}

update(node<<1, start, (start+end)>>1, L, R);

update((node<<1)+1, ((start+end)>>1)+1, end, L, R);

ST[node] = ST[node<<1] + ST[(node<<1)+1];

}

When using lazy update, why do I get wrong answer if I put

**if(L > end || R < start) return;**

first thing in the function.

If this current range is completely outside our required range, why are we concerned about performing pending updates on it?