Intel Interview Question for Software Engineer / Developers






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

int gcd(int a, int b) {
  return b == 0 ? a : a > b ? gcd(b, a%b) : gcd(a, b%a); 
}

hm... i'm not sure :(

- Zaphod April 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

good solution

- Anonymous March 14, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

it should be

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a%b) ; 
}

- parixit September 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

euclid s algorithm

int gcd ( int a, int b ) {
if ( b == 0 )
return a;
else return gcd ( b , a - b * ( a / b ) );

}

- ozanokanavci April 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice and efficient solution

- Denny May 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

we should find all the factors of the two numbers,
for (i=0;i<n;i++)
{
if(n%i ==0)
factor[j] = n;
j++;
}

factor would be array that is storing all factors of the number. similarly we can get for second number. one thing we can check is whether the number is even or odd, if its odd, then 2,4,6,8,0 or any even number cannnot be a factor of that and will save half of the computation.

then we can check the length of factor array and start with the one that has less elements, because of our loop, the factor array will contain elements in sorted manner. we can then check from the smaller array and then return the answer.

please give comments if this sounds ok or not

- jack.watermelon April 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class Numbers {
	
	
	
	public static int gcdTC(int a,int b){
		int  result;
		try{
			result = (a > b) ? gcd(b, (a%b) ) : gcd(a, (b%a) );
		}catch(ArithmeticException ex){
			result = (a == 0) ? a : b; 
		}
		return result;
	}
	
	
	public static void main(String[] args){
		int x = gcd(12,12);
		System.out.println("GCD is == " + x);
	}

}

- modi.osu September 28, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

int gcd(int a, int b)
{
        int r;
        while(b != 0)
        {
                r = a % b;
                a = b;
                b = r;
        }
        return a;
}

- Anonymous June 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

How to find GCD of n numbers efficiently

- Anonymous January 08, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

For F**k sake ... gimme a break ... go to a school first then prepare for an interview

- game April 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what is your point anyway?

- Anonymous April 04, 2010 | Flag


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