判断是不是子字符串
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Solver solver = new Solver(); solver.solve(in, out); out.close(); } public static boolean isSubsequence(String s, String t) { int index = -1; char []s1 = s.toCharArray(); for(char c:s1) { index = t.indexOf(c,index+1); if(index == -1) { return false; } } return true; } static class Solver { public void solve(InputReader in, PrintWriter out) { Scanner sc = new Scanner(System.in); String s = sc.next(); String t = sc.next(); boolean flag = isSubsequence(s, t); System.out.println(flag); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } } }