| ||A palindrome is a string that reads the same forward and backward. Not all strings are palindromes and we are going to fix that.|
In this problem we consider four edit operations:
- Insert a character at any position of a string (including the beginning and the end)
- Delete a character at any position of a string
- Change a character at any position of a string
- Swap any two different characters (not necessarily adjacent)
You can apply the first three operations any number of times, but the last operation can be applied at most once.
You are given a String initial. Return the minimal number of operations needed to make a palindrome from it.
|Method signature:||int getEditDistance(String initial)|
|(be sure your method is public)|
|-||initial will contain between 1 and 50 lowercase letters ('a'-'z'), inclusive.|
|The string is already a palindrome.|
|We can delete the first letter to make a palindrome.|
|We can change 'c' to 'a' to get a palindrome in one operation.|
|Insert 'b' after the first character.|
|Swap 'd' with 'a' in the middle.|