Function that returns true if s contains three consecutive 1 's
static boolean check ( String s ) { int n = s . length ( ) ; for ( int i = 2 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '1' && s . charAt ( i - 1 ) == '1' && s . charAt ( i - 2 ) == '1' ) return true ; } return false ; }