Range Queries
← Back to Segment Trees and Fenwick Trees
Answer aggregate queries (sum, min, max, GCD) over a contiguous subarray in O(log n) after O(n) preprocessing. Without these structures, each query would be O(n).
← Back to Segment Trees and Fenwick Trees
Answer aggregate queries (sum, min, max, GCD) over a contiguous subarray in O(log n) after O(n) preprocessing. Without these structures, each query would be O(n).