how to reaarange the string

You are given a string as an input. Rearrange the characters of the string such that no character appears in its original position.
If the rearrangement is possible, print the rearranged string else print 'Not possible'.

Sample Input:
Case 1:

Case 2:

Sample Output:
Case 1:
dcaabcdab(It is one of the possible valid rearrangements of 'aabccbadd')

Case 2:
Not possible

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!