Company: Tally_24july
Difficulty: medium
Palindrome Transformation Problem Description Ravi has two strings, s1 and s2. He wants to make string s2 a palindrome of s1 by replacing some letters with any alphabet. Help Ravi by telling him the minimum number of letters he needs to replace to make s2 the palindrome of s1. Input Format The first line will be string s1. The second line will be string s2. Output Format Print the minimum number of letters to replace or -1 if it is impossible to make s2 as the palindrome of s1. Examples Example 1: Input: abcda abcda Output: 2 Explanation: Given s1 = "abcda" and s2 = "abcda" . To make s2 a palindrome of s1 , s2 must become the reverse of s1 . The reverse of s1 ( "abcda" ) is "adcba" . Now, compare s2 ( "abcda" ) with reversed_s1 ( "adcba" ) character by character: Position 0: s2[0] ('a') vs reversed_s1[0] ('a') - Match, no change needed. Position 1: s2[1] ('b') vs reversed_s1[1] ('d') - No match, needs replacement. Position 2: s2[2] ('c') vs reversed_s1[2] ('c') - Match, no change neede