You are viewing a single comment's thread. Return to all comments →
import java.util.Scanner;
public class Solution {
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int numLines = sc.nextInt(); for (int i = 0; i < numLines; i++) { String myStr = sc.nextLine(); System.out.println(myStr.replaceAll("(?i)\\b(\\w+)(\\s+\\1)+\\b", "$1")); } sc.close(); }
}
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 →
import java.util.Scanner;
public class Solution {
}