I'm wondering what if the problem asks us to find the number of distinct triplets, instead of number of index triplets. Can we still solve it in O(n^2)? What's the good way to do it?

No. In the original problem, we can get the number of solutions from indices directly. But if you want all the combinations of numbers, you need to look back to all the numbers before index start. Hence, it will be O(n^3).