We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public class HackerRank {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int c =0;
String ptr = "[#@]?[hH][aA][cC][kK][eE][rR]{2}[aA][nN][kK]";
//String ptr = "[#@]?hackerRank"; // es lo mismo con insentitive
Pattern p = Pattern.compile(ptr);
//Pattern p = Pattern.compile(ptr,Pattern.CASE_INSENSITIVE);
int numOfLines = 0;
if(sc.hasNextLine()){
numOfLines = Integer.valueOf(sc.nextLine());
}
while(numOfLines > 0){
if(!sc.hasNextLine()) break;
String line = sc.nextLine();
Matcher m = p.matcher(line);
if(m.find()){
c++;
}
numOfLines--;
}
System.out.print(c);
```
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
HackerRank Tweets
You are viewing a single comment's thread. Return to all comments →
JAVA 8.0
` import java.util.Scanner; import java.util.regex.*;
/** * * @author EMmanuel */
public class HackerRank { public static void main(String[] args) {
}