Topic description
Niu Niu got a treasure map. Following the instructions of the treasure map, Niu Niu found a treasure box. There was a trap on the treasure box. The trap would display two strings s and t each time. According to ancient legends, Niu Niu needs to answer each time whether t is a subsequence of s. Note that the subsequence is not required to be continuous in the original string, such as the string abc, its subsequence has 8 kinds of {empty string, a, b, c, ab, ac, bc, abc}.
Enter description:
Each input contains a test case. Each test case contains two lines of visible ASCII strings of no more than 10 spaces in length.
Output description:
Output a line of "Yes" or "No" to indicate the result.
Example 1
enter
x.nowcoder.com ooo
output
Yes
1 import java.util.Scanner; 2 3 /** 4 * 藏宝图 5 * @author Dell 6 * 7 */ 8 public class Main { 9 static public String s = "x.nowcoder.com"; 10 static public String t = "ooo"; 11 static public void f() { 12 int j = 0; 13 for (int i = 0; i < s.length(); i++) { 14 15 if (s.charAt(i)==t.charAt(j)) { 16 j++; 17 } 18 if (j==t.length()) { 19 System.out.println("Yes"); 20 return; 21 } 22 } 23 System.out.println("No"); 24 } 25 public static void main(String[] args) { 26 Scanner sc = new Scanner(System.in); 27 s= sc.nextLine(); 28 t = sc.nextLine(); 29 f(); 30 } 31 }