Samsung Interview Question for Software Engineer / Developers


Team: networking
Country: India
Interview Type: In-Person




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

public class rock{
public static void main(String[] args){
int num;
for(int n:num)
{
if(n==0)
n=1
else n=0;
}
for(int i=num.length; i>=0; i--)
{
if(i==num.length)
num[i]=get(add(i,1));
num1[i]=get1(add(num[i],1);
else if(i!=0)
num[i]=get(add(num1[i+1],num[i]));
num1[i]=add1(add(num1[i+1], num[i]));
else
num1[i]=0;
num1[i]=add1(add(num1[i+1], num[i]));


}
}
static int add(int x, int y)
{
if(x=0 && y=0)
return 0;
if(x=1 && y=1)
return 10;
if(x=0 && y=1)
return 01;
if(x=1 && y=0)
return 01;

}
int static get1( int s)
{
switch(s)
case 00: return 0; break;
case 10: return 1; break;
case 01: return 0; break;
case 11: return 1; break;
}
int static get( int s)
{
switch(s)
case 00: return 0; break;
case 10: return 0; break;
case 01: return 1; break;
case 11: return 1; break;
}
}

- Anonymous October 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class rock{
public static void main(String[] args){
int num;
for(int n:num)
{
if(n==0)
n=1
else n=0;
}
for(int i=num.length; i>=0; i--)
{
if(i==num.length)
num[i]=get(add(i,1));
num1[i]=get1(add(num[i],1);
else if(i!=0)
num[i]=get(add(num1[i+1],num[i]));
num1[i]=add1(add(num1[i+1], num[i]));
else
num1[i]=0;
num1[i]=add1(add(num1[i+1], num[i]));


}
}
static int add(int x, int y)
{
if(x=0 && y=0)
return 0;
if(x=1 && y=1)
return 10;
if(x=0 && y=1)
return 01;
if(x=1 && y=0)
return 01;

}
static int get1( int s)
{
switch(s)
case 00: return 0; break;
case 10: return 1; break;
case 01: return 0; break;
case 11: return 1; break;
}
static int get( int s)
{
switch(s)
case 00: return 0; break;
case 10: return 0; break;
case 01: return 1; break;
case 11: return 1; break;
}
}

- Anonymous October 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Either you people are not thinking simple or I have gone smarter than Deniss Ritchie lately:

int main()
    {
        // n = number whose 2's complement you wish to take
       int n;
       int twoComplementOfN = (~n) & 0x00000001;
       
       return twoComplementOfN ;
    }

- Adorn November 16, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

just flip the bits and add 1

int cmpl(int n){
	return ~(n)+1;	
   }

- anonymous November 16, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int cmpl(int n){ 
        return 0 - n;
}

- Abhi November 18, 2014 | 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