Hello,
First I get a number (numbers of string to check) then get the pattern.
If the string contains the pattern, print Yes otherwise No.
For example:
4 quera102
quEra0012
qu0erraa12
sN0Ap12
qurra00L
No
Yes
No
No
I wrote the below code but I get 71 from 100.
package My; import java.util.*; public class NewMain { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); String pattern = scanner.next(); String []myString = new String[n]; for (int i = 0; i< n ; i++) { myString[i] = scanner.next(); } boolean flag = true; for (int i = 0; i< n ; i++) { flag = true; for (int j = 0 ; j < myString[i].length(); j++) { int indexOf = pattern.indexOf(myString[i].charAt(j)); if (indexOf == -1) { flag = false; break; } } if (flag == false) { System.out.println("No"); } else { System.out.println("Yes"); } } } }