Start or end of a word

Report a typo

The first line of the input contains a sequence of letters.

The second line of the input contains some text.

Your task is to determine if any of the words of this text start or end with the sequence specified in the first line of the input. If there is, you should output "YES", otherwise output "NO". A word can only contain symbols of the English alphabet. You should ignore the case while searching for matches.

Sample Input 1:

ing
Java is the most popular programming language

Sample Output 1:

YES

Sample Input 2:

press
Regular expressions is hard to read, isn't it?

Sample Output 2:

NO

Sample Input 3:

ho
Wow! How awesome is that!

Sample Output 3:

YES

Sample Input 4:

ONE
ponep,onep!

Sample Output 4:

YES
Write a program in Java 17
import java.util.*;
import java.util.regex.*;

public class Main {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String part = scanner.nextLine();
String line = scanner.nextLine();

// write your code here
}
}
___

Create a free account to access the full topic