题解 | #藏宝图#
藏宝图
https://www.nowcoder.com/practice/74475ee28edb497c8aa4f8c370f08c30
//主要是有顺序要求用双指针吧 // import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); String t = sc.next(); int valid = t.length(); for(int i = 0, j = 0; i < s.length() && j < t.length();) { if(s.charAt(i) == t.charAt(j)) { i++; j++; valid--; } else { i++; } } if(valid == 0) { System.out.println("Yes"); } else { System.out.println("No"); } } }