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=scanner.nextInt();scanner.nextLine();//one or more spaces before tagname. So \\s*Patternpattern=Pattern.compile("<\\s*(\\w+)[^>]*>");TreeSet<String>tags=newTreeSet<String>();for(inti=0;i<n;i++){Matchermatcher=pattern.matcher(scanner.nextLine());while(matcher.find())tags.add(matcher.group(1));}System.out.println(String.join(";",tags));}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Detect HTML Tags
You are viewing a single comment's thread. Return to all comments →
Java 15