Discretization
When the number range is very large and the numbers are very sparse, we can discretize the input numbers so that we can keep the ordering of the numbers while saving them in a much smaller array.
For example, the input array is:
If we need to create an array covering the range we need to create one with length 20001, but actually there are just 3 numbers in it.
We can turn it into
with the following mapping
Implementation
Problem
327. Count of Range Sum (Hard) When using with BIT
Last updated