题解 | BFS
BFS
https://www.nowcoder.com/practice/22da7730da5d4a129a188ba24d22f2bf
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.next().toLowerCase();
//法1:截取字符串
// for(int i = 0; i < s.length(); i++){
// if(s.substring(i,i+3).equals("bob")){
// System.out.print(i);
// break;
// }
// }
//法2:indexof定位
int index = s.indexOf("bob");
System.out.print(index);
}
}
查看21道真题和解析