If we have reached last state and previous state is not 1 , then check next character . If next character is ' \0' , then return true , else false
if ( curr_state == 3 && prev_state != 1 ) return ( str [ index + 1 ] == ' \0' ) ; index ++ ;