Step 1: Sort the list to make it easier to find triplets
[-4, -1, -1, 0, 1, 2]
Why: Sorting helps us use two pointers to find pairs that sum to a target efficiently
Step 2: Fix first number at index 0 (-4), set left=1, right=5
[-4, -1, -1, 0, 1, 2] ↑fixed at -4, left=1, right=5
Why: We try to find two numbers that sum to 4 (0 - (-4))
Step 3: Sum = -4 + (-1) + 2 = -3, less than 0, move left pointer right
[-4, -1, -1, 0, 1, 2] fixed=-4, left=2, right=5
Why: Sum too small, increase left to get larger sum
Step 4: Sum = -4 + (-1) + 2 = -3, still less than 0, move left pointer right
[-4, -1, -1, 0, 1, 2] fixed=-4, left=3, right=5
Why: Sum still too small, move left pointer again
Step 5: Sum = -4 + 0 + 2 = -2, less than 0, move left pointer right
[-4, -1, -1, 0, 1, 2] fixed=-4, left=4, right=5
Why: Sum still less than zero, move left pointer
Step 6: Sum = -4 + 1 + 2 = -1, less than 0, move left pointer right
[-4, -1, -1, 0, 1, 2] fixed=-4, left=5, right=5
Why: Left and right pointers meet, no triplet with fixed -4
Step 7: Fix first number at index 1 (-1), set left=2, right=5
[-4, -1, -1, 0, 1, 2] ↑fixed at -1, left=2, right=5
Why: Try to find two numbers that sum to 1 (0 - (-1))
Step 8: Sum = -1 + (-1) + 2 = 0, found triplet [-1, -1, 2], move left and right pointers
[-4, -1, -1, 0, 1, 2] triplets=[[-1,-1,2]], left=3, right=4
Why: Sum zero means valid triplet, move pointers to find more
Step 9: Sum = -1 + 0 + 1 = 0, found triplet [-1, 0, 1], move left and right pointers
[-4, -1, -1, 0, 1, 2] triplets=[[-1,-1,2],[-1,0,1]], left=4, right=3
Why: Sum zero again, but pointers crossed, stop for this fixed
Step 10: Fix first number at index 2 (-1), skip because same as previous fixed to avoid duplicates
[-4, -1, -1, 0, 1, 2]
Why: Avoid duplicate triplets by skipping same fixed number
Step 11: Fix first number at index 3 (0), set left=4, right=5
[-4, -1, -1, 0, 1, 2] ↑fixed at 0, left=4, right=5
Why: Try to find two numbers that sum to 0 (0 - 0)
Step 12: Sum = 0 + 1 + 2 = 3, greater than 0, move right pointer left
[-4, -1, -1, 0, 1, 2] fixed=0, left=4, right=4
Why: Sum too big, decrease right pointer
Step 13: Left and right pointers meet, stop for fixed 0
[-4, -1, -1, 0, 1, 2]
Why: No more pairs to check
Step 14: Fix first number at index 4 (1), stop because left pointer would be right pointer
[-4, -1, -1, 0, 1, 2]
Why: No enough elements left for triplet
Result: Triplets found: [-1, -1, 2] -> [-1, 0, 1]