# Tag Archives: Swap-Program

## Generate an Array such with elements maximized through swapping bits

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:… Read More »

## Minimum swaps required to move all vowels occurs after consonants in a given string

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 »

## Minimum number of adjacent swaps required to convert a permutation to another permutation by given condition

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 »

## Lexicographically largest string possible in one swap

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

## Maximize distance between smallest and largest Array elements by a single swap

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 »

## Minimize swaps to rearrange array such that parity of index and corresponding element is same

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 »

## Sort permutation of N natural numbers using triple cyclic right swaps

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 »

## Lexicographically smallest array formed by at most one swap for every pair of adjacent indices

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 »

## Smallest number possible by swapping adjacent even odd pairs

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 »

## Minimum number of swaps required to make the string K periodic

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 »

## Maximize Array sum by swapping at most K elements with another array

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 »

## Java Program to Swap two Variables

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

## Python Program to swap two numbers without using third variable

Given two variables n1 and n2. The task is to swap the values of both the variables without using third variable. Examples: X : 10… Read More »

## Python Program to Swap Two Variables

Given two variables x and y, write a Python program to swap their values. Let’s see different methods in Python to do this task. Method… Read More »

## C program to swap adjacent characters of a String

Given a string str, the task is to swap adjacent characters of this string in C. Examples: Input: str = “geeks” Output: NA Not possible… Read More »