Mindbending Product Problem Statement

You are given an array ARR of size N. Your task is to create a Product Array P of the same size such that P[i] is the product of all the elements in ARR except ARR[i]. Note that you are not allowed to use the division operator.

Example:

Input:
ARR = [1, 2, 3, 4, 5]
Output:
[120, 60, 40, 30, 24]
Explanation:

The Product Array is created as follows:

  • P[0] = 2 * 3 * 4 * 5 = 120
  • P[1] = 1 * 3 * 4 * 5 = 60
  • P[2] = 1 * 2 * 4 * 5 = 40
  • P[3] = 1 * 2 * 3 * 5 = 30
  • P[4] = 1 * 2 * 3 * 4 = 24

Constraints:

  • 1 ≤ T ≤ 50
  • 1 ≤ N ≤ 10
  • 1 ≤ ARR[i] ≤ 20
  • Time Limit: 1 sec
Satyam Kashyap
6d
You have to construct a Product Array 'P' of the same size such that P[i] is equal to the product of all the elements of ARR except ARR[i]. The .
Help your peers!
Add answer anonymously...
Wipro Project Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter