Before learning MO’s Algorithm, let us take a quick look at the prerequisites through which we can solve it. In competitive programming , we come across questions which involves queries mostly static queries which are given as vectors or arrays . Each such queries represent a run in the code. So, do you think running the code each time for every query operation is fine? Obviously, it is a brute force approach and it will fail most of the times in a coding platform as there will be a huge number of queries. So, what we can do? Can we always break up the array in two parts for like we do in Binary Search ? Not really! And nor it will be beneficial. Let us consider a particular part of the array may be some x th part of the array size. We divide the array into x parts to reduce our time complexity. By using complex mathematical calculations – differentiation we found out that this x is nothing but, where n is the size of the array. We come to the ...