Given an array arr[] of N integers, and an array Q[] of M pairs, where a pair represents a query of the form {L, R},… Read More

# Tag Archives: MO’s Algorithm

Mo’s Algorithm is a generic algorithm. It can be used in many problems that require processing range queries in a static array, i.e., the array… Read More

Given a N-ary tree with some colour associated with every node and Q queries. Each query contains two integers A and X. The task is… Read More

Given an array arr[] of N elements, the task is to answer Q queries each having two integers L and R. For each query, the… Read More

Given an array arr[] consisting of N elements and Q queries represented by L and R denoting a range, the task is to print the… Read More

Given an array arr[] of N elements and two integers A to B, the task is to answer Q queries each having two integers L… Read More