Algorithm - 회문 문자열

Algorithm - 회문 문자열

public class Main {

public static void main( String [] args) throws IOException {

BufferedReader reader = new BufferedReader( new InputStreamReader( System . in ));

StringBuilder builder = new StringBuilder();

String text = reader.readLine().toLowerCase();

int count = text. length ();

for ( int i = text. length () - 1 ; i > = 0 ; i - - ) {

builder.append(text. charAt (i));

}

for ( int i = 0 ; i < text. length (); i + + ) {

if (text. charAt (i) = = builder. charAt (i)) {

count - - ;

} else {

count + + ;

}

}

if (count > 0 ) {

System . out . println ( "NO" );

} else {

System . out . println ( "YES" );

}

}

}

from http://kdg-is.tistory.com/195 by ccl(A) rewrite - 2021-09-10 00:27:11