I am familiar with Mo's algorithm and there are multiple blogs explaining it!
But this problem Link although based on square root decomposition only had a very nice idea. Can someone post similar problems? According to Editorialist this approach is known as Caching of updates/queries ( Google tells some random stuff and nothing useful).
Thanks!
http://codeforces.net/blog/entry/16099 first problem here uses idea of maintaining buffer of updates. i think it is similar.
https://www.hackerrank.com/contests/snapdeal-hackathon-round-2/challenges/recommendation-engine https://www.codechef.com/DCL1501/problems/DCL2015E
Both these can be solved with the same idea but there are also ways to do it in better complexity