title: Find triangles in a list of random numbers
body: <p>I'm taking each element as "sum", "first" and "sec". If (first + sec &lt; sum) I'll make a hashset(tmp) of these 3 and put this hashset into a larger hashset(triangle) containing all tmp hashsets. This removes duplicate combinations of 3 numbers. Here's my code. It works but is there any better solution? </p>
  
  <pre><code>public void findTriangle(int[] a){
  
      HashSet&lt;HashSet&lt;Integer&gt;&gt; triangle = new HashSet&lt;HashSet&lt;Integer&gt;&gt;();
      HashSet&lt;Integer&gt; tmp;
      for(int i=0;i&lt;a.length;i++){
          int sum=a[i];
          for(int j=0;j&lt;a.length;j++){
              int first = a[j];
              if(first!=sum){
                  for(int k=0;k&lt;a.length;k++){
                      int sec = a[k];
                      if(sec!=first &amp;&amp; sec!=sum &amp;&amp; (first + sec &lt; sum)){
                          tmp = new HashSet&lt;Integer&gt;();
                          tmp.add(first);
                          tmp.add(sec);
                          tmp.add(sum);
                          triangle.add(tmp);
                      }
                  }       
              }
          }
  
      }
  
      for(HashSet&lt;Integer&gt; hs : triangle)
          System.out.println(hs);
  }
  </code></pre>