edit distance algo for k palindrom questions