Questions related to strings

## Interchanging first and second halves of stings

Given two strings and . Create two new strings by exchanging the first half and second half of one of the strings with the first… Read More »

## Merge two strings in chunks of given size

Given two strings ‘a’ and ‘b’ and a number k, our aim is to merge the strings into a string s such that it contains… Read More »

## Make a lexicographically smallest palindrome with minimal changes

Given a string S. Print the lexicographically smallest string possible. You can make minimal changes to the characters in the string and you can permute… Read More »

## Program for length of a string using recursion

Given a string calculate length of the string using recursion. Examples: Input : str = “abcd” Output :4 Input : str = “GEEKSFORGEEKS” Output :13… Read More »

## Generate all the binary number from 0 to n

Given a positive integer number n generate all the binary number from 0 to n. Examples: Input : 5 Output : 0 1 10 11… Read More »

## Longest palindrome subsequence with O(n) space

Given a sequence, find the length of the longest palindromic subsequence in it. Examples: Input : abbaab Output : 4 Input : geeksforgeeks Output :… Read More »

## Count consonants in a string (Iterative and recursive methods)

Given a string, count total number of consonants in it. A consonant is a English alphabet character that is not vowel (a, e, i, o… Read More »

## Count of number of given string in 2D character array

Given a 2-Dimensional character array and a string, we need to find the given string in 2-dimensional character array such that individual characters can be… Read More »

## Check if it is possible to convert one string into another with given constraints

Given two strings contains three characters i.e ‘A’, ‘B ‘and ‘#’ only. Check is it possible to convert first string into another string by performing… Read More »

## Check if actual binary representation of a number is palindrome

Given a non-negative integer n. The problem is to check if binary representation of n is palindrome or not. Note that the actual binary representation… Read More »

## Reduce Hamming distance by swapping two characters

Given two strings S and T. Find the positions of two letters to be swapped in S so that the hamming distance between strings S… Read More »

## Smallest number with sum of digits as N and divisible by 10^N

Find the smallest number such that the sum of its digits is N and it is divisible by . Examples : Input : N =… Read More »

## Convert string X to an anagram of string Y with minimum replacements

Given two strings X and Y, we need to convert string X into an anagram of string Y with minimum replacements. If we have multiple… Read More »

## K distant string

Given a string of length n and a non-negative integer k. Find k distant string of given string. Distance between two letters is difference between… Read More »

## Check if both halves of the string have at least one different character

Earlier we have discussed on how to check if both halves of the string have same set of characters. Now, we further extend our problem… Read More »