Hello! I think most on here understand that the solution is based on the 2SUM problem. However, most of us (including myself) have encountered the dreadful TLE. So, the trick (as written in the comment below) is to avoid summing the same THREE elements again. That's it!

Feel free to let me know should you have any queries OR if this solution can be improved upon!

```
public List<List<Integer>> threeSum(int[] num) {
List<List<Integer>> resultList = new ArrayList<List<Integer>>();
if(num.length <= 2 || num == null)
return resultList;
Arrays.sort(num);
HashSet<ArrayList<Integer>> tracker = new HashSet<ArrayList<Integer>>();
int len = num.length;
for(int i = 0; i < len-2; i++){
//left
int j = i+1;
//right
int k = len-1;
while(j < k){
int sum = num[i] + num[j] + num[k];
if(sum == 0){
ArrayList<Integer> temp = new ArrayList<Integer>();
temp.add(num[i]);
temp.add(num[j]);
temp.add(num[k]);
if(tracker.add(temp)){
resultList.add(temp);
}
j++;
k--;
//HERE'S THE TRICK!
//We want to avoid summing up the same three elements again.
//So, we move the left and right pointers until they are different from previous result.
while(j < k && num[j] == num[j-1]){
j++;
}
while(j < k && num[k] == num[k+1]){
k--;
}
}
else if(sum < 0)
j++;
else if(sum > 0)
k--;
}
}
return resultList;
}
```