Zygodrome Number | C # implementation to check if N is a zygodrome number ; Function to check if N is an zygodrome number ; convert N to string ; Adding a space at the beginning and end of the string ; Traverse the string ; If any character is not same as prev and next then return false ; Driver code
using System ; class GFG { static bool iszygodromeNum ( int N ) { String s = N . ToString ( ) ; s = ' ▁ ' + s + ' ▁ ' ; for ( int i = 1 ; i < s . Length - 1 ; i ++ ) { if ( s [ i ] != s [ i - 1 ] && s [ i ] != s [ i + 1 ] ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { int n = 1122 ; if ( iszygodromeNum ( n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }