Minimum reduce operations to convert a given string into a palindrome | Java program to count minimum reduce operations to make a palindrome ; Returns count of minimum character reduce operations to make palindrome . ; Compare every character of first half with the corresponding character of second half and add difference to result . ; Driver code
import java . io . * ; class GFG { static int countReduce ( String str ) { int n = str . length ( ) ; int res = 0 ; for ( int i = 0 ; i < n / 2 ; i ++ ) res += Math . abs ( str . charAt ( i ) - str . charAt ( n - i - 1 ) ) ; return res ; } public static void main ( String [ ] args ) { String str = " abcd " ; System . out . println ( countReduce ( str ) ) ; } }