Step 1: Sort the array to make it easier to avoid duplicates and use two pointers
[-2, -1, 0, 0, 1, 2]
Why: Sorting helps us skip duplicates and use two pointers efficiently
Step 2: Fix first number at index 0 (-2), then fix second number at index 1 (-1)
[-2, -1, 0, 0, 1, 2]
First = -2, Second = -1
Why: We pick first two numbers and look for remaining two that sum to target minus their sum
Step 3: Use two pointers: left at index 2 (0), right at index 5 (2), sum = -2 + -1 + 0 + 2 = -1
[-2, -1, 0, 0, 1, 2]
Pointers: left=2, right=5, sum=-1
Why: Sum less than target, move left pointer right to increase sum
Step 4: Move left pointer to index 3 (0), sum = -2 + -1 + 0 + 2 = -1 again
[-2, -1, 0, 0, 1, 2]
Pointers: left=3, right=5, sum=-1
Why: Still less than target, move left pointer again
Step 5: Move left pointer to index 4 (1), sum = -2 + -1 + 1 + 2 = 0, quadruplet found
[-2, -1, 0, 0, 1, 2]
Quadruplet: [-2, -1, 1, 2]
Why: Sum equals target, record quadruplet and move pointers to find others
Step 6: Fix first number at index 0 (-2), second number at index 2 (0), use two pointers left=3 (0), right=5 (2)
[-2, -1, 0, 0, 1, 2]
First=-2, Second=0, left=3, right=5
Why: Try new second number to find other quadruplets
Step 7: Sum = -2 + 0 + 0 + 2 = 0, quadruplet found
[-2, -1, 0, 0, 1, 2]
Quadruplet: [-2, 0, 0, 2]
Why: Sum equals target, record quadruplet
Step 8: Fix first number at index 1 (-1), second number at index 2 (0), left=3 (0), right=4 (1)
[-2, -1, 0, 0, 1, 2]
First=-1, Second=0, left=3, right=4
Why: Try new first number to find other quadruplets
Step 9: Sum = -1 + 0 + 0 + 1 = 0, quadruplet found
[-2, -1, 0, 0, 1, 2]
Quadruplet: [-1, 0, 0, 1]
Why: Sum equals target, record quadruplet
Result: [-2, -1, 1, 2]
[-2, 0, 0, 2]
[-1, 0, 0, 1]