Check whether the number can be made palindromic after adding K | Java program to check whether the number can be made palindrome number after adding K ; Function to check whether a number is a palindrome or not ; Convert num to string ; Comparing kth character from the beginning and N - kth character from the end . If all the characters match , then the number is a palindrome ; If all the above conditions satisfy , it means that the number is a palindrome ; Driver code
import java . util . * ; class GFG { static void checkPalindrome ( int num ) { String str = Integer . toString ( num ) ; int l = 0 , r = str . length ( ) - 1 ; while ( l < r ) { if ( str . charAt ( l ) != str . charAt ( r ) ) { System . out . print ( " No " ) ; return ; } l ++ ; r -- ; } System . out . print ( " Yes " ) ; return ; } public static void main ( String args [ ] ) { int n = 19 , k = 3 ; checkPalindrome ( n + k ) ; } }