Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Product Except Self

Python data engineering interview problem. Difficulty: beginner. Pattern: Arrays. About 10 minutes. Free to practice.

For each index, product of all other elements without division. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

Implement product_except_self(nums: list) -> list where output[i] is the product of all nums[j] for j != i. Do not use division.

Constraints

  • Do not use division.
  • Length of nums is at least 2.

Examples

Input: product_except_self([1, 2, 3, 4]) Output: [24, 12, 8, 6] Left/right products multiply.

Topics: lakebench, python, prefix, product.

More Python interview questions · All interview problems · Learn data engineering

beginner

Product Except Self

Interview-style drill: For each index, product of all other elements without division.

Implement `product_except_self(nums: list) -> list` where output[i] is the product of all nums[j] for j != i. Do not use division. Example: `[1, 2, 3, 4]` → `[24, 12, 8, 6]`. Keep the harness.