Data Structures, Algorithms, Leetcode, Segment Tree, Programming.
counting sort. Since the value range is [1, 100], then the time complexity is constant, therefore the time complexity of one query is also controlled at O(logN). Algorithm code is as follows: const int N = 1e5 + 9; // Each node (both internal and leaf nodes) of the segment tree is represented // as