Engineering Interview Questions in Sunnyvale, CA | Glassdoor

Engineering Interview Questions in Sunnyvale, CA

1,333

Engineering interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

Product Design Engineer at Apple was asked...

Jun 13, 2016
 What are 5 different variables of a coil spring you can change to affect spring force?3 AnswersMaterial, wire diameter, wire cross sectional shape, coil diameter, coil length5 different variables that can affect the springs force. 1.) Wire length 2.) Coil pitch 3.) Wire cross-sectional shape 4.) Material of the coil 5.) Coil diameter1. WD 2. OD 3. Active coils 4. Material 5. Free Height

ASIC Verification Engineer at Zoran was asked...

Sep 9, 2010

Oct 5, 2010
 Partition an array in such way zeros to be moved on the left side of the array, other numbers on the right side of the array. Extra storage not allowed, only in-place.6 Answersint j = 0; for (int i = 0; i j) { vec[i] = vec[j]; vec[j++] = 0; } }correction: the loop body should be: if (vec[i] == 0) { if (i > j) { vec[i] = vec[j]; vec[j] = 0; } j++; }I progress a zero pointer from right to left, and a non-zero pointer from left to right, then swap them until they meet in the middle. int j=N-1; int i=0; for(i=0; i=0; j--) if(array[j]==0) break; //j points to right-most zero while(j>i){ swap(i,j) for(; i=0; j--) if(array[j]==0) break; }Show More Responsesexit=0; i=0; j=0; while((exit==0)&&(i<=vector.length)) { swapped=0; j=i; if(vector[i]!=0) while((swapped==0)&&(j<=vector.length)) { if(vector[j]==0) { vector[j]=vector[i]; vector[i]=0; swapped=1; } if(j==vector.length) swapped=exit=1; j++; } i++; }Similar to how partitioning is done in quicksort.Tweaking vsp's imp for readability...it is the optimal on this forum in O(n). int zeroInsertPosition = 0; for (int i = 0; i < c; i++) { if (vec[i] == 0) { if (i != zeroInsertPosition) { vec[i] = vec[zeroInsertPosition]; vec[zeroInsertPosition] = 0; } zeroInsertPosition++; } } Also change the i

Software Engineer Intern at Motorola Mobility was asked...

Mar 19, 2009
 Write a function in Java that will take a sorted array of ints, possibly with duplicates, and compact the array removing all the duplicate numbers. That is, if the contains the numbers - 1, 3, 7, 7, 8, 9, 9, 9, 10, then when the function returns, the contents should be - 1, 3, 7, 8, 9, 10. Be sure your answer is as efficient as possible. Describe the efficiency of your algorithm using big O notation.5 Answerscreate temp array; starting from the second element copy the i'th char if input[i-1] != input[i] return tempoh efficiency is O(n)you can't create a temp array because you don't know the size until after you process. you could count the number of dupes in one pass, then allocate the array, then do the compacting. or you could allocate the array equal to the size of the original and accept that some elements will be null (or -1, or whatever). or you could use some dynamic data structure like an ArrayList to build the compacted list and convert it to an array at the end (ArrayList.toArray(...)). regardless, it's still O(n) and uses 2x the memory. makes me think there's a more elegant solution though.Show More Responsesdo bitwise XOR of consecutive numbers. When the xor is 0, you know the number is duplicate. It will require single pass thru the array to identify number of duplicates in the array.you can also use 2 index, at the beginning they both = 0, then you will have a previous and a next, if previous value = next value increment next index until next value != previous value then increment previous index by 1 and assign "next value" to it and so forth until you "next index reach the end of the array and then increment all previous index assigning null or -1. O(n) without using 2x memory. Anyway, I hope it is not too confusing, its late but I hope you got the big picture.

Software Engineer at Yahoo was asked...

Nov 26, 2013
 fair, lot of position related tech questions. Given a string "Keyword" find whether the characters exist in a String "Target" in the same order but not necessarily next to each other Keyword cat aaa Target cbate abcde Output YES NO4 AnswersBoth Longest Common Subsequence and Linear solution will work.int index = 0; for (int i = 0; i < target.length(); i++) { if target[i] = keyword[index]; index++; if (index == keyword) return true; } return false;...how do you think to use iterative method....blah..recursive: - (BOOL)findString:(NSString *)keyword inMixedString:(NSString *)target { if(!keyword || !target) return NO; if([keyword length] == 0) return YES; if([target length] == 0) return NO; NSString *kLecter = [keyword substringWithRange:NSMakeRange(0, 1)]; NSString *tLecter = [target substringWithRange:NSMakeRange(0,1)]; if([kLecter isEqualToString:tLecter]) keyword = [keyword substringFromIndex:1]; return [self findString:keyword inMixedString:[target substringFromIndex:1]]; return NO; }Show More Responsesobviously without return NO at the end

Front End Software Engineer at Yahoo was asked...

Oct 29, 2010
 Design a data structure to store sparse 2D matrix which contains only 0 or 1. then write function to add 2 such matrix. 4 AnswersI first proposed to use array to remember each 1 location. then find out it is quite expensive to do the addition. with the interviewer's help, I result in using hash table. then I was asked to write hash function. It was quite challenge for me. But the interviewer was really nice and very helpful to push me to the limit.use run-length encoding.store each row as a decimal for ex: if the row is 1011 -> store it as 13!Show More ResponsesSince all values are mod 2 you can pack 64 entries together into on int64_t. You can then add two matrices by XORing each entry.

Software Engineer at eBay was asked...

Mar 14, 2013
 Some probability question 1) given a rand5() function which provide a random number between 1-5 at equal probability. Write a rand7() fuction to provide a random number between 1-7 with equal probability...5 AnswersAbs(2*rand5()-3 )int value = rand5()-1 + (rand5()-1)*5; if (value < 21) { return( value / 3 +1); }int value = rand5() - 1 + (rand5() * 5); if(value < 21) { return (value%7 +1); }Show More Responsesint value=0 for (i=0; i<5; i++) { value+=(rand5()-1);} return (value%3+1);The answer Abs(2*rand5()-3 ) does not generate uniformly distributed random numbers. It is wrong!

Nov 12, 2009