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]. You must solve it without division and in O(n) time.
Input: nums = [1,2,3,4]
Output: [24,12,8,6]
Topics: arrays
Asked by: Amazon, Google, Meta, Microsoft, Apple, Bloomberg, Adobe
Time complexity: O(n). Space complexity: O(1) excluding output.