Comments

Hello, I was wondering how would you convert the following into querying for minimum? I've tried substituting the logic in the loop but was getting some weird answer. Thanks

int query(int l, int r) {  // sum on interval [l, r)
  int res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) res += t[l++];
    if (r&1) res += t[--r];
  }
  return res;
}

EDIT: I figured it out forgot to change build() as well.