Check if mirror image of a number is same if displayed in seven segment display | Java Program to check if mirror image of a number is same if displayed in seven segment display ; Return " Yes " , if the mirror image of number is same as the given number Else return " No " ; Checking if the number contain only 0 , 1 , 8. ; Checking if the number is palindrome or not . ; If corresponding index is not equal . ; Driver Code
import java . io . * ; class GFG { static String checkEqual ( String S ) { for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) != '1' && S . charAt ( i ) != '0' && S . charAt ( i ) != '8' ) { return " No " ; } } int start = 0 , end = S . length ( ) - 1 ; while ( start < end ) { if ( S . charAt ( start ) != S . charAt ( end ) ) { return " No " ; } start ++ ; end -- ; } return " Yes " ; } public static void main ( String [ ] args ) { String S = "101" ; System . out . println ( checkEqual ( S ) ) ; } }