The size of the output (worst case) is a lower bound on the complexity.
Since there are possibly O(n^3) such triplets, the complexity cannot be O(n).
For example if the array is sorted from lowest to highest, you will have n choose 3 such triplets which is order of n^3.
If the question refers to finding the number of triplets, here is the most efficient solution I saw: