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.
La salida de mi programa es igual a la esperada (verificadas con editores hex) pero el summit marca error.
publicstaticvoidmain(String[]args){Stringregex="\\b(\\w+)\\s+\\1\\b";Patternp=Pattern.compile(regex,Pattern.CASE_INSENSITIVE);Scannerin=newScanner(System.in);intnumSentences=Integer.parseInt(in.nextLine());while(numSentences-->0){Stringinput=in.nextLine();Matcherm=p.matcher(input);// Check for subsequences of input that match the compiled patternwhile(m.find()){Stringgroup=m.group();String[]temp=group.split(" ");input=input.replaceAll(group,temp[0]);m=p.matcher(input);}// Prints the modified sentence.System.out.println(input);}in.close();}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Regex 2 - Duplicate Words
You are viewing a single comment's thread. Return to all comments →
La salida de mi programa es igual a la esperada (verificadas con editores hex) pero el summit marca error.