Find a word with a given length

Report a typo

For a given number N and a line with text, output "YES" if this line contains a word with exactly N symbols, otherwise output "NO".

A word can contain only symbols of the English alphabet.

The previous statement also means that there can't be any digits inside a word.

Sample Input 1:

3
Java is the most popular programming language

Sample Output 1:

YES

Sample Input 2:

11
Regular expression is hard to read, isnt it?

Sample Output 2:

NO

Sample Input 3:

4
Wow! How awesome is that!

Sample Output 3:

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);
int size = Integer.parseInt(scanner.nextLine());
String line = scanner.nextLine();

// write your code here
}
}
___

Create a free account to access the full topic