Given two arrays arr1[] and arr2[] of size N, the task is to count the minimum number of swaps of same-indexed elements from both the… Read More

# Tag Archives: Swap-Program

Given an array arr[], the task is to rearrange the array elements by swapping adjacent elements such that no element remains at same position after… Read More

Given an array arr[] of unique elements and three integers X, A and B. The task is to print the maximum possible distance between elements… Read More

Given an array arr[], the task is to generate a modified array such that all its elements are maximized by swapping of bits.Examples: Input: arr[]… Read More

Given a string S, the task is to count the number of positions by which the vowels have to be moved such that all the… Read More

Given a permutation P of size N, having values from 1 to N. the task is to find the minimum number of adjacent swaps required… Read More

Given string str of length N, the task is to obtain the lexicographically largest string by at most one swap. Note: The swapping characters might not… Read More

Given an arr[] consisting of N elements in the range [1, N], the task is to maximize the distance between smallest and largest array element… Read More

Given an array A[], the task to find minimum swapping operations required to modify the given array A[] such that for every index in the… Read More

Given an array arr[] of size N which contains the permutations of the N natural numbers, the task is to sort the permutations of N… Read More

Given an array A[] of length N, the task is to find lexicographically smallest array by swapping adjacent elements for each index atmost once. Thus,… Read More

Given a numeric string str, the task is to find the smallest integer that can be formed by swapping adjacent digits of distinct parity. Examples:… Read More

Given a string S of length N, and an array A, consisting of lowercase letters. Also given a positive integer K. the task is to… Read More

Given two arrays A and B of size N and an integer K, the task is to find the maximum possible sum of array A… Read More

Given two numbers x and y, we need to swap their values Examples: Input : x = 10, y = 20; Output : x =… Read More