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 letacter is not same as prev and next then return false ; Driver code
function iszygodromeNum ( N ) { let s = N . toString ( ) ; s = ' ' + s + ' ' ; for ( i = 1 ; i < s . length - 1 ; i ++ ) { if ( s [ i ] != s [ i - 1 ] && s [ i ] != s [ i + 1 ] ) { return false ; } } return true ; } let n = 1122 ; if ( iszygodromeNum ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;