题解 | BFS

BFS

https://www.nowcoder.com/practice/22da7730da5d4a129a188ba24d22f2bf

#include <iostream>
using namespace std;

int main() {
    string s;
    cin>>s;
    int l=s.length();
    int find=1;
    for(int i=0;i<l;i++)
    {
        if((s[i]=='B'||s[i]=='b')&&(s[i+1]=='o'||s[i+1]=='O')&&(s[i+2]=='B'||s[i+2]=='b'))
        {
            cout<<i<<endl;
            find=0;
            return 0;
        }
        else continue;
    }
    if(find) cout<<"-1"<<endl;
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务