addRange method
Adds delta to the logical range l..r (inclusive) in O(1).
Audited: 2026-06-12 11:26 EDT
Implementation
void addRange(int l, int r, int delta) {
// Reject out-of-range AND reversed ranges (l > r). Without the l > r guard a
// reversed range writes a positive delta at l and a negative at r+1 < l,
// silently corrupting the recovered array instead of being a clean no-op.
if (l < 0 || r >= _d.length - 1 || l > r) return;
_d[l] += delta;
_d[r + 1] -= delta;
}