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
3d
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 Accenture Data Engineering Analyst interview questions & answers
Popular interview questions of Data Engineering Analyst
Top HR questions asked in Accenture Data Engineering Analyst
>
Accenture Data Engineering Analyst Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app