Skip to content

Tag Archives: Swap-Program

Given an array arr[] consisting of N pairs, where each pair represents the value and ID respectively, the task is to check if it is… Read More
Given a singly Linked List, the task is to swap the first odd valued node from the beginning and the first even valued node from… Read More
Given two binary arrays arr1[] and arr2[] of the same size, the task is to make both the arrays equal by swapping pairs of arr1[… Read More
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
Given an array arr[], the task is to rearrange the array elements by swapping adjacent elements such that no element remains at the same position… 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 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