
Asked in Accenture
Product Of Array Except Self Problem Statement
You are provided with an integer array ARR
of size N
. You need to return an array PRODUCT
such that PRODUCT[i]
equals the product of all the elements of ARR
except ARR[i]
.
Example:
Input:
T = 2
N = 4
ARR = [1, 2, 3, 4]
N = 3
ARR = [2, 3, 4]
Output:
[24, 12, 8, 6]
[12, 8, 6]
Constraints:
1 ≤ T ≤ 100
0 ≤ N ≤ 105
0 ≤ ARR[i] ≤ 105
- Time Limit: 1 sec
Note:
Each product may exceed integer limits, so take modulo MOD = 109 + 7
to keep results in bounds.
Follow Up:
Can you solve the problem using O(1) additional space?

AnswerBot
5mo
The problem requires returning an array where each element is the product of all elements in the input array except itself.
Iterate through the array twice to calculate the product of all elements to t...read more
Help your peers!
Add answer anonymously...
Top Data Engineering Analyst Interview Questions Asked at Accenture
Q. What are parquet files?
Q. Can you explain your academic projects?
Q. Suppose there is a file with 100 columns, and you only want to load 10 specific ...read more
Interview Questions Asked to Data Engineering Analyst at Other Companies
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

