Data Structures, Algorithms, Leetcode, Segment Tree, Programming.
set the bit when initializing. else { int mid = (L + R) / 2; build(A, rt * 2, L, mid); build(A, rt * 2 + 1, mid + 1, R); push_up(rt); } } // rt: current tree node number // [L, R]: the interval corresponding to node rt // [ql, qr]: the interval range we want to query, // in other words [ql, qr] is