Given two variables, x, and y, swap two variables without using a third variable. Method 1 (Using Arithmetic Operators): Example 1: The idea is to… Read More
Tag Archives: Swap-Program
Given two arrays arr1[] and arr2[] of size N each, the task is to find the minimum number of interchange of the same indexed elements… Read More
Given two integers N and K and an array of N positive integers (i.e., a0, a1, a2…., an-1), the task is to find the minimum… Read More
Given a binary string s of length N, the task is to find the lexicographically smallest string using infinite number of swaps between 0’s and… Read More
Given a doubly linked list having all unique elements and two keys X and Y, the task is to swap nodes for two given keys… Read More
Given an array A of size n, the task is to check if the array can be sorted in increasing order, if the only operation… Read More
Given a binary circular array arr[] of size N, the task is to find the minimum swaps to group all 0s together in the array.… Read More
Given a string s containing lowercase English alphabet characters. The task is to calculate the number of distinct strings that can be obtained after performing… Read More
A significant benefit of object-oriented programming is the reusability of code which eliminates redundant coding. An important feature of C++ is called templates. Templates support… Read More
Given two strings A and B consisting of unique lowercase letters, the task is to check if both these strings can be made equal by… Read More
Given a String S of length N, two integers B and C, the task is to traverse characters starting from the beginning, swapping a character… Read More
Given a String S of length N, two integers B and C, the task is to traverse characters starting from the beginning, swapping a character… Read More
The task at hand involves manipulating a string S of length N, given as input. The string is subjected to a series of B swaps,… Read More
Given two integers N and K, the task is to calculate the minimum number of adjacent swaps of digits required to make the integer N… Read More
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