Solutions has both of these. However, only having either one will prevent the duplicate triplet. Can you give an example that can be caught one case and not in the other?
if (i > 0 && arr[i] == arr[i - 1]) // skip same element to avoid duplicate triplets
continue;
and
while (left < right && arr[left] == arr[left - 1])
left++; // skip same element to avoid duplicate triplets
while (left < right && arr[right] == arr[right + 1])
right--; // skip same element to avoid duplicate triplets