# Product of Array Except Self (Practice 5028): Rehearsal Interviewers use this pattern to test whether you can state the invariant before coding. Here is a compact rehearsal note. ## Approach A left-prefix pass then a right-suffix pass in the same output array, no division. ```python def product_except_self(a): n=len(a);out=[1]*n;p=1 for i in range(n): out[i]=p;p*=a[i] p=1 for i in range(n-1,-1,-1): out[i]*=p;p*=a[i] return out ``` ## Complexity Linear in the dominant input size for the scan; heap/tree variants add a log factor. ## Interview pitfalls State the invariant out loud, name the complexity, then code. Skipping the invariant is the usual fail mode. ## Practicing out loud Narrate the approach, complexity and one edge case in under a minute. Disclosure: I work on Linkjob AI, a real-time interview assistant. If you want live practice help, see [real-time interview help](https://www.linkjob.ai/).