fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. System.out.println("telegram");
  14. ArrayList<String> ar = new ArrayList<>();
  15. ar.add("https://i...content-available-to-author-only...e.com/f6RTkG");
  16. System.out.println(fillGaps(ar));
  17.  
  18. }
  19. public static List<String> fillGaps(List<String> deps) {
  20. HashSet<String> tmp = new HashSet<>();
  21. for (String value : deps) {
  22. String start = "";
  23. for (String el : value.split("/")) {
  24. if (start.equals("")) {
  25. start = el;
  26. } else {
  27. start += "/" + el;
  28. //tmp.add(start); был тут
  29. }
  30.  
  31. } tmp.add(start); // стал тут
  32. }
  33. return new ArrayList<>(tmp);
  34. }
  35. }
Success #stdin #stdout 0.15s 36284KB
stdin
Standard input is empty
stdout
telegram
[https://i...content-available-to-author-only...e.com/f6RTkG]