文章
3
粉丝
0
获赞
15
访问
1.2k
#include<bits/stdc++.h>
#include<stack>
using namespace std;
bool isValid(string &str){
stack<char> s;
int index=0;
for(char i='a';i<='z';i++){
s.push(i);//将26个字母按顺序入栈
while(!s.empty()&&s.top()==str[index]){//看看出栈顺序是不是26个字母顺序
s.pop();
index++;
}
}
return index==str.size();
}
int main(){
string s;
while(cin>>s){
if(isValid(s)){
cout<<"yes"<<endl;
}else{
&nbs...
登录后发布评论
暂无评论,来抢沙发