What Is This LOL!
All submissions for this problem are available.
While in ISM, you spend most of your time in chatting, either on facebook, gtalk or through sms. You noticed that lots of your friends write "lol", whenever you tell them a joke. You noticed that lol is a special word as it is equal to itself when reversed. You found out that such words are called palindrome. Now you see some words that are not palindromes but after certain operations(swapping) those words may or may not be transformed in palindromes. You try to find out the minimum number of steps performed for this transformation. You can only swap two adjacent letters at a time. You have to find out the minimum number of swapping required to perform the operation
The first line of input will be an integer T , the number of test cases. For each test case, there will be a separate line entry containing a string up to 80 lowercase letters
For each test case there will be one line output. This line will print the minimum number of swaps, or "Not Possible" if it is not possible to transform the input to a palindrome
Input: 4 ffi aktktinan dhanbad wcgyecvfggqrwrvfyeg Output: 1 9 Not Possilbe 24
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.