title: java- removing substring in a list of strings
body: <p>Consider the case of a list of strings
  example : list=['apple','bat','cow,'dog','applebat','cowbat','dogbark','help']</p>
  
  <p>The java code must check if any element of string is a subset of another element  and if it is then larger string element must be removed.</p>
  
  <p>so in this case strings 'applebat','cowbat','dogbark, are removed.</p>
  
  <p>The approach I have taken was to take two lists and iterate over them in the following way,</p>
  
  <pre><code>ArrayList&lt;String&gt; list1 = new ArrayList&lt;String&gt;(strings);
  ArrayList&lt;String&gt; list2 = new ArrayList&lt;String&gt;(strings);
  for(int i = 0; i&lt;list1.size();i++)
      {
          String curr1 = list1.get(i);
  
          for(int j = 0;j&lt;list2.size();j++)
          {
              String curr2 = list2.get(j);
  
              if(curr2.contains(curr1)&amp;&amp;!curr2.equals(curr1))
              {
                  list2.remove(j);
                  j--;
          }
          }
      }
  </code></pre>
  
  <p><strong>IMPORTANT</strong> I have lists with the sizes of 200K to 400K elements.I would like to find a way to improve performance. I even tried hashsets but they were not much help.I am facing issues with the time taken by the program.</p>
  
  <p>Can any one suggest any improvements to my code or any other approaches in java to improve performance??</p>