Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Product of Array Except Self (medium)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given an array of integers, return a new array where each element at index i of the new array is the product of all the numbers in the original array except the one at i. You must solve this problem without using division.

Examples

    • Input: [2, 3, 4, 5]
    • Expected Output: [60, 40, 30, 24]
    • Justification: For the first element: 3*4*5 = 60, for the second element: 2*4*5 = 40, for the third element: 2*3*5 = 30, and for the fourth element: 2*3*4 = 24.
    • Input: [1, 1, 1, 1]
    • Expected Output: [1, 1, 1, 1]

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible