This folder contains a simple example implementation of Mo's algorithm in Java.
Files:
MoAlgorithm.java— Example implementation that answers number-of-distinct-values queries on a static integer array using Mo's algorithm (offline queries).
Quick usage example (conceptual):
- Build your input array
int[] arr. - Create an array of
MoAlgorithm.Queryobjects with 0-based inclusive ranges and original indices. - Call
int[] answers = MoAlgorithm.mosDistinct(arr, queries);.
This repository is a general-purpose Java collection of practice problems. The implementation here is intentionally small and dependency-free.