iLabs Interview Question for Tech Leads


Country: India
Interview Type: In-Person




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

public void printDuplicate(int[] test){
int temp=1;
for(int i=0;i<test.length;i++){
if(temp%test[i]==0){
System.out.println("duplicate prime number"+test[i])
temp=temp*test[i];
}

}


}

- OTR November 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

statement

temp=temp*test[i];

should be out of if block. otherwise, temp is always 1 until we get 1.

- pradeep December 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

OTR how about overflow ?
Stop posting the easy jungle questions.

- Guest _BS_

- Luri Covalisin (aka algos) November 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Guest_BS..Don't be selfish, it's not about being easy or difficult..its about recording which companies are asking what type of questions.

- OTR November 24, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public void printDuplicate(int[] array){
Set set=new HashSet();
for(int i=0;i<array.length;i++){
Boolean flag=set.add(array[i]);
if(!flag) System.out.println("duplicate element"+array[i]);
}
}

- pantbrijesh20 November 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what if 1 element is present more than 2 times?
it will be prointed more than once.

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

I think question is not clear -- Prime numbers are unique,their is no concept of duplicate prime numbers.

- Naresh February 06, 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