# Tag Archives: Constructive Algorithms

## Lexicographically smallest string which differs from given strings at exactly K indices

Given two strings S1 and S2 of length N and a positive integer K, the task is to find the lexicographically smallest string such that… Read More »

## Partition of a set into K subsets with equal sum using BitMask and DP

Given an integer array arr[] of consisting of N integers, the task is check if it is possible to divide the given array into K… Read More »

## Count of indices in an array that satisfy the given condition

Given an array arr[] of N positive integers, the task is to find the count of indices i such that all the elements from arr… Read More »

## Minimum inversions required so that no two adjacent elements are same

Given a binary array arr[] of size N. The task is to find the minimum number of inversions required so that no two adjacent elements… Read More »

## Check if two strings can be made equal by swapping one character among each other

Given two strings A and B of length N, the task is to check whether the two strings can be made equal by swapping any… Read More »

## Form N by adding 1 or 2 in minimum number of operations X where X is divisible by M

Given a number N, the task is to form N (from 0) by adding 1 or 2 in the minimum number of operations X such… Read More »

## Minimum operations required to make the string satisfy the given condition

Given a string str, the task is to make the string start and end at the same character with the minimum number of given operations.… Read More »

## Reduce every element of the array to it’s half retaining the sum zero

Given an array arr[] of N integers with total element sum equal to zero. The task is to reduce every element to it’s half such… Read More »

## Check whether the string S1 can be made equal to S2 with the given operation

Given two string S1 and S2, the task is to check whether both the strings can be made equal by performing the given operation on… Read More »

## Minimum number to be added to all digits of X to make X > Y

Given two numbers X and Y of the same length, the task is to find the minimum number d that needs to be added to… Read More »

## Sort the given stack elements based on their modulo with K

Given a stack of integers and an integer K, the task is to sort the elements of the given stack using another stack in the… Read More »

## Make the array non-decreasing with the given operation

Given an array arr[] of size N, the task is to check if it is possible to make the array non-decreasing by applying the given… Read More »

## Find the maximum element in the array other than Ai

Given an array arr[] of size N. The task is to find maximum element among N – 1 elements other than arr[i] for each i… Read More »

## Find the Kth position element of the given sequence

Given two integers N and K, the task is to find the element at the Kth position if all odd numbers from 1 to N… Read More »