[Solved] How can we find number of distinct elements in a given submatrix? [closed]
It depends how many queries you can expect, and the number of identical queries you can expect. One approach is to “memoize” queries, simply to store each query and result, and look that up before doing more serious work. A more problem-specific approach – probably what your teacher is after – is to compute distinct … Read more