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);// Pattern pattern = Pattern.compile("(ok){3,}"); //WORKSPatternpattern=Pattern.compile("(ok)\\1\\1");// \\1 means anything in first captured-group. Here ok is in first ()Matchermatcher=pattern.matcher(scanner.nextLine());System.out.println(matcher.find());}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Capturing & Non-Capturing Groups
You are viewing a single comment's thread. Return to all comments →
Java 15: