4 ms·
Does the range query aggregate the elements in range? If the aggregation operation forms a group (follows associativity law, has inverse) you can use prefix sum
by facturi 2y ago
Does the range query aggregate the elements in range? If the aggregation operation forms a group (follows associativity law, has inverse) you can use prefix sum data structures like Fenwick tree.
If it doesn't have inverse so that you cannot subtract prefix sum, sparse table can be used.