Got this in an interview. The question is very similar to the very famous question [Find a triplet that sum to a given value](https://www.geeksforgeeks.org/find-a-triplet-that-sum-to-a-given-value/), with a slight difference. Here we want to print *ALL* triplets, not just one. 

The array can contain duplicates. 

For example consider the following array: 
`[1, -1, 2, 0, -2, 4, -2, -2, 4]`

The output should be: 

```
[1, -1, 0]
[4, -2, -2]
[2, -2, 0]

```

The order of triplets or the order of numbers in the triplets are not important.

Using sorting or using a set there are n^2 solutions (like the solution in the link above). But how to make sure we only print unique triplets? One solution I can think of is to use a set for tracking which triplets we have seen so far. But not sure if that's the best way and or if there are other solutions using sorting, etc to generate unique triplets.