This question evaluates skills in array manipulation, in-place algorithm design, numerical stability and edge-case reasoning (such as handling multiple zeros and large products), plus selection and ranking competencies for extracting the top-k elements.
Given an integer array nums of length n, return an array ans where:
ans[i]
= product of all
nums[j]
for
j != i
Given an unsorted array of numbers and an integer k, return the k largest elements (order does not matter unless specified).
Discuss time/space trade-offs for different approaches.