Check if the number is valid when flipped upside down | C # implementation of the approach ; Function that returns true if str is Topsy Turvy ; For every character of the string ; If the current digit cannot form a valid digit when turned upside - down ; Driver code
using System ; class GFG { static bool topsyTurvy ( char [ ] str ) { for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == '2' str [ i ] == '4' str [ i ] == '5' str [ i ] == '6' str [ i ] == '7' str [ i ] == '9' ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String str = "1234" ; if ( topsyTurvy ( str . ToCharArray ( ) ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }