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.
importjava.io.*;importjava.util.*;importjava.util.regex.Pattern;importjava.util.regex.Matcher;publicclassSolution{publicstaticvoidmain(String[]args){Scannerscanner=newScanner(System.in);intn=Integer.parseInt(scanner.nextLine());//Merge all input togetherStringinput="";for(inti=0;i<n;i++)input=input+scanner.nextLine()+" ";intt=Integer.parseInt(scanner.nextLine());for(inti=0;i<t;i++){Stringus_word=scanner.nextLine();Stringuk_word=us_word.replaceAll("ze$","se");Patternpattern=Pattern.compile(us_word+"|"+uk_word);Matchermatcher=pattern.matcher(input);intcount=0;while(matcher.find())count++;System.out.println(count);}}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The British and American Style of Spelling
You are viewing a single comment's thread. Return to all comments →
Java 15: