## Samsung Interview Question

SDE-2s**Country:**United States

**Interview Type:**In-Person

```
#include<iostream>
using namespace std;
int main()
{
int x[5]= {2,4,3,5,6};
int prod[5];
int temp = 1;
for (int i = 0;i < 5;i++){
prod[i] = temp;
temp = temp*x[i];
}
temp = 1;
for (int j = 4;j >=0;j--){
prod[j] = prod[j]*temp;
temp = temp*x[j];
}
for (int i=0; i<5; i++)
cout << prod[i] << " ";
return 0;
}
```

```
public static void main(String args[])
{
int array[]={2,4,3,5,6};
int multi=1;
for(int i=0;i<array.length;i++)
{
multi=multi*array[i];
}
System.out.println("multi: "+multi);
for(int i=0;i<array.length;i++)
{
array[i]=multi/array[i];
}
for(int i:array)
{
System.out.print(i+" ");
}
}
```

Cumulative Multiplication from the left ( discounting at the point ):

- SK September 04, 2015{1, 2, 8, 24, 120}

Cumulative Multiplication from the right (discounting at the point):

{360,90,30,6,1}

Now multiply these 2 arrays together