Step 1: Sort the list to organize numbers
[-4, -1, -1, 0, 1, 2]
Why: Sorting helps to use two pointers efficiently and avoid duplicates
Step 2: Fix first number at index 0 (-4), set left=1, right=5
fixed=-4, left=-1, right=2
Why: Start searching pairs that sum with -4 to zero
Step 3: Sum = -4 + (-1) + 2 = -3 < 0, move left pointer right
fixed=-4, left=-1 (index 2), right=2
Why: Sum too small, increase left to get bigger sum
Step 4: Sum = -4 + (-1) + 2 = -3 < 0, move left pointer right
fixed=-4, left=0 (index 3), right=2
Why: Still too small, move left pointer
Step 5: Sum = -4 + 0 + 2 = -2 < 0, move left pointer right
fixed=-4, left=1 (index 4), right=2
Why: Sum less than zero, move left pointer
Step 6: Sum = -4 + 1 + 2 = -1 < 0, move left pointer right
fixed=-4, left=2 (index 5), right=2
Why: Left pointer met right, no triplet with fixed -4
Step 7: Fix first number at index 1 (-1), set left=2, right=5
fixed=-1, left=-1, right=2
Why: Try next fixed number to find triplets
Step 8: Sum = -1 + (-1) + 2 = 0, record triplet [-1, -1, 2], move left and right skipping duplicates
triplets: [[-1, -1, 2]]; left=3, right=4
Why: Found valid triplet, move pointers to find others
Step 9: Sum = -1 + 0 + 1 = 0, record triplet [-1, 0, 1], move left and right
triplets: [[-1, -1, 2], [-1, 0, 1]]; left=4, right=3
Why: Found another triplet, pointers crossed, move to next fixed
Step 10: Fix first number at index 2 (-1), skip because same as previous fixed
skip fixed=-1 at index 2
Why: Avoid duplicate triplets by skipping same fixed number
Step 11: Fix first number at index 3 (0), set left=4, right=5
fixed=0, left=4, right=5
Why: Try next fixed number
Step 12: Sum = 0 + 1 + 2 = 3 > 0, move right pointer left
fixed=0, left=4, right=4
Why: Sum too big, decrease right pointer
Step 13: Left pointer met right, no triplet with fixed 0
end fixed=0
Why: No more pairs to check
Result: [-1, -1, 2] -> [-1, 0, 1]