We’re preparing your current view and syncing the latest data.
Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
You must write an algorithm that runs in O(n) time and without using the division operation.
An integer array nums of length n.
An integer array answer where each answer[i] is the product of all elements of nums except nums[i].
2 <= nums.length <= 10^5 -30 <= nums[i] <= 30 The product of any prefix or suffix of nums fits in a 32-bit integer.