# Category Archives: Competitive Programming

## Number of Larger Elements on right side in a string

Given a string, find count of number of larger alphabets for every character of the string. Examples: Input : str = “abcd” Output : 3… Read More »

## Find (a^b)%m where ‘b’ is very large

Given three numbers a, b and m where 1<=a, m<=10^6. Given very large 'b' containing up to 10^6 digits and m is a prime number,… Read More »

## Minimum operations required to make all the elements distinct in an array

Given an array of N integers. If a number occurs more than once, choose any number y from the array and replace the x in… Read More »

## Check if a M-th fibonacci number divides N-th fibonacci number

Given two numbers M and N, the task is to check if the M-th and N-th Fibonacci numbers perfectly divide each other or not. Examples:… Read More »

## Water drop problem

Consider a pipe of length L. The pipe has N water droplets at N different positions within it. Each water droplet is moving towards the… Read More »

## Difference between the summation of numbers whose frequency of all digits are same and different

Given an array of N integers, find the difference between the summation of numbers whose frequency of all digits are same and different. For e.g.… Read More »

## Maximize the number of segments of length p, q and r

Given a rod of length L, the task is to cut the rod in such a way that the total number of segments of length… Read More »

## Minimum steps to reach end from start by performing multiplication and mod operations with array elements

Given start, end and an array of N numbers. At each step, start is multiplied with any number in the array and then mod operation… Read More »

## Pair of arrays with equal sum after removing exactly one element from each

Given K arrays of different size. The task is to check if there exist any two arrays which have the same sum of elements after… Read More »

## Extended Mo’s Algorithm with ≈ O(1) time complexity

Given an array of n elements and q range queries (range sum in this article) with no updates, task is to answer these queries with… Read More »

## Find the number of operations required to make all array elements Equal

Given an array of N integers, the task is to find the number of operations required to make all elements in the array equal. In… Read More »

## Minimum adjacent swaps to move maximum and minimum to corners

Given N number of elements, find the minimum number of swaps required so that the maximum element is at the beginning and the minimum element… Read More »

## Largest connected component on a grid

Given a grid with different colors in a different cell, each color represented by a different number. The task is to find out the largest… Read More »

## Number of distinct prime factors of first n natural numbers

In this article, we study an optimized way to calculate the distinct prime factorization up to n natural number using O O(n*log n) time complexity… Read More »

## Maximize the bitwise OR of an array

Given an array of N integers. The bitwise OR of all the elements of the array has to be maximized by performing one task. The… Read More »