The O(1) extra space solution uses the output array for prefix products, then multiplies in suffix products in a second pass. First pass: answer[i]= product of all elements before i.
Start with answer[0]=1, then answer[i]=answer[i−1]×nums[i−1]. Second pass: track suffix (product of elements after current index). For each i from n−1 down to 0: answer[i]=answer[i]×suffix, then suffix=suffix×nums[i]. After both passes, answer[i] = product of all elements except nums[i]. Time: O(n), Space: O(1) excluding output.