class Solution {
public List<List<Integer>> threeSum(int[] nums) {
HashSet<List<Integer>> hashSet=new HashSet<>();
HashMap<Integer,Integer> map=new HashMap<>();
for (int i=0;i<nums.length;i++){
map.put(nums[i],i);
}
for (int i=0;i<nums.length-1;i++){
for (int j=i+1;j<nums.length;j++){
int c=0-nums[i]-nums[j];
if (map.containsKey(c)&&i!=map.get(c)&&j!=map.get(c)){
List<Integer> list=new LinkedList<>();
list.add(nums[i]);
list.add(nums[j]);
list.add(c);
Collections.sort(list);
hashSet.add(list);
}
}
}
List<List<Integer>> rs=new ArrayList<>(hashSet);
return rs;
}
}