Tutorials
Courses
Go Premium
Data Structure
Java
Python
HTML
Interview Preparation
DSA
Practice Problems
C
C++
Java
Python
JavaScript
Data Science
Machine Learning
Courses
Linux
DevOps
SQL
Web Development
System Design
Aptitude
GfG Premium
Similar Topics
Web Technologies
32.1K+ articles
DSA
20.0K+ articles
frequency-counting
745+ articles
subarray
658+ articles
number-digits
612+ articles
array-range-queries
376+ articles
DFS
359+ articles
cpp-map
287+ articles
two-pointer-algorithm
213+ articles
sliding-window
204+ articles
MO's Algorithm
7 posts
Recent Articles
Popular Articles
Maximum occurring element in a subarray range (Mode queries)
Last Updated: 23 July 2025
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}, the task is to find the maximum occurring element in t...
read more
DSA
array-range-queries
subarray
cpp-map
frequency-counting
MO's Algorithm
Working and need of Mo's Algorithm
Last Updated: 23 July 2025
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 values do not change betwee...
read more
DSA
array-range-queries
MO's Algorithm
Count of distinct colors in a subtree of a Colored Tree with given min frequency for Q queries
Last Updated: 15 July 2025
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 to count all distinct colors in a subtr...
read more
DSA
array-range-queries
DFS
sliding-window
two-pointer-algorithm
MO's Algorithm
Range Queries for count of Armstrong numbers in subarray using MO's algorithm
Last Updated: 15 July 2025
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 number of Armstrong numbers in the subarray [...
read more
DSA
array-range-queries
number-digits
MO's Algorithm
Range Queries to count elements lying in a given Range : MO's Algorithm
Last Updated: 23 July 2025
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 and R. For each query, find the number of elements i...
read more
DSA
array-range-queries
MO's Algorithm
Queries for count of even digit sum elements in given range using MO's Algorithm
Last Updated: 12 July 2025
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 task is to find the number of elements in the sub...
read more
DSA
array-range-queries
number-digits
MO's Algorithm
Count of odd and even parity elements in subarray using MO's algorithm
Last Updated: 10 January 2024
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 count of odd and even parity elements in the su...
read more
DSA
subarray
MO's Algorithm
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our
Cookie Policy
&
Privacy Policy
Got It !