text: 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.
  CalvinWestwood + 0 comments
  Your expected output contains domain names not present in the input HTML code
  jackbanh + 0 comments
  This question needs a bit more polish. The instructions and test cases could use more clarity.
  - "www." and "ww2." are expected to be filtered out but this instruction is easy to miss.
  - In the real world, you cannot assume that "" and "example.org" resolve to the same place
  - The test case inputs are truncated so it's harder to debug
  - There is no hint for which special characters are valid in a domain name
  mai_the_09 + 0 comments
  Java 8 Solution
  public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = Integer.parseInt(in.nextLine().trim()); Pattern pa = Pattern.compile("http[s]?:\\/\\/(ww[w2]\\.)?(([a-zA-Z0-9\\-]+\\.)+([a-zA-Z\\-])+)"); TreeSet<String> set = new TreeSet<>(); while (n-- > 0) { String input = in.nextLine(); Matcher ma = pa.matcher(input); while (ma.find()) set.add(ma.group(2)); } for (String str : set) { System.out.print((str != set.last()) ? str + ";" : str); } } }
  Sort 113 Discussions, By:
  Please Login in order to post a comment