top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

C: string swapping to convert minimum no of characters in both the string.

+2 votes
680 views

Input: Two strings of same length (say "ababab" "bababa")
Output: Two strings with minimum unique character used in each one ("bbbbbb" & "aaaaaa" for above example)

You can swap A[i] and B[i] for all i between 1 and N, inclusive. You cannot swap two characters within A, or within B. you can only swap a character in A with the character at the same index in B, and with no other character. You can perform this operation zero or more times.

Modify the strings through the operations in such a way that the number of unique characters in the strings is minimum.

posted Aug 9, 2015 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

For eg: z is changed to y & not y to z ....the value of alphabets are changed from right to left ( eg.in the word apple ,the value of 'e' is reduced to 'd' until it becomes a palindrome or when the value becomes 'a'.

+8 votes

Convert the given string into palindrome with minimum number of appends(at end of the given string). O(n) algorithm will be appreciated ??

Input :=> Malayal
Output :=> Malayalam

+6 votes

A chessboard was given to us. Where in there was a Knight and King was placed on certain positions.
Our aim is to reach the king from the knight in minimum no of counts.As we know, knight can either
move 2 steps vertical/horizontal and 1 step horizontal/vertical. same goes here as well.

Input

Position of Knight.
Position of King.
...