Samsung Interview Question for SDE-2s


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
12
of 12 vote

Cumulative Multiplication from the left ( discounting at the point ):
{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

- SK September 04, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nice one!

- MehrdadAP September 04, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Was this riddle an actual Samsung SDE-2 interview question? What skill are they testing?

- dev September 04, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

2

- Mohammad Faisal September 20, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

this will fail in the case of 1,3,0,4,6 check this out

- ujjawal sharma August 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

this will fail in the case of 1,3,0,4,6 check this out

- ujjawal sharma August 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int main()
{
int x[5]= {1,1,1,1,1}, y[5]={2,4,3,5,6};
for(int i=0; i<5; i++)
{
for (int j=0; j<5; j++)
{
 if(i==j)
    continue;
 x[i] = x[i]*y[j];

}
}
for (int i=0; i<5; i++)
cout <<  x[i] << " ";

return 0;
}

- Ramya November 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int main()
{
int x[5]= {1,1,1,1,1}, y[5]={2,4,3,5,6};
for(int i=0; i<5; i++)
{
for (int j=0; j<5; j++)
{
 if(i==j)
    continue;
 x[i] = x[i]*y[j];

}
}
for (int i=0; i<5; i++)
cout <<  x[i] << " ";

return 0;
}

- ramya November 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int x[5]= {1,1,1,1,1}, y[5]={2,4,3,5,6};
for(int i=0; i<5; i++)
{
for (int j=0; j<5; j++)
{
 if(i==j)
    continue;
 x[i] = x[i]*y[j];
}}

- ramya November 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#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;
}

- Anonymous November 21, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

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+" ");
		}
		
	}

- Anonymous September 13, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Division is not allowed. Please refer solution given by SK, this is correct one.

- Razz September 13, 2015 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

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+" ");
		}
		
	}

- Ghosh September 13, 2015 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More