leetle

Daily challenge for 2025-06-03

154. Product of Array Except Self

Write a function solve that takes an array nums of n integers and returns an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without using division.

Example:
Input: [1,2,3,4]
Output: [24,12,8,6]
Explanation: output[0] = 2*3*4 = 24, output[1] = 1*3*4 = 12, output[2] = 1*2*4 = 8, output[3] = 1*2*3 = 6

Run this challenge interactively in Python or JavaScript when the app loads.