# Engineering Interview Questions in Sunnyvale, CA

Engineering interview questions shared by candidates

## Top Interview Questions

### Product Design Engineer at Apple was asked...

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 length 5 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 diameter 1. WD 2. OD 3. Active coils 4. Material 5. Free Height |

### ASIC Verification Engineer at Zoran was asked...

You have 2 pieces of rope, each of which burns from one end to the other in 30 minutes (no matter which end is lit). If different pieces touch, the flame will transfer from one to the other. You cannot assume any rope properties that were not stated. Given only 1 match, can you time 45 minutes? 49 AnswersTake one rope (Rope A), place it down as a circle. Light match and start burning rope A at the tips that are touching. When the rope completely burns out, 15 minutes will have passed (since both ends are burning and being consumed at once). Hold the second rope (Rope B) straight and place one end so that it will immediately catch fire when the two burning points from (Rope A) finally touch and are just about to burn out. Thus 15 minutes on Rope A + 30 minutes on Rope B gives you 45 mins. How about this: Fold the first rope double so the ends touch. Lay it down and lay the second rope so it touches the fold of the first rope. Light the ends of the first rope. After 15 minutes the second rope should ignite. Once second rope finishes burning it is 45 minutes. Same principle as above, I just don't want to sit there for 15 minutes in order to light the second rope.... :-) Make a T. Simple Show More Responses Light both ropes at the same time with the match: ------------* () *---------- || then place the two ropes next to each other with the burning ends opposite each other: this way one of the ropes burns left to right, while the other is burning right to left. ----------* *---------- In 15 min the two burning ends will be next to each other. -----* *----- Great Puzzle, thanks! ** You cannot assume any rope properties that were not stated Burn like this *-------- ===> After 30mins, Rope A finished burning, and both ends of Rope B start burning burn one rope, wait till it gets to the half way point, then you transfer the first one to the second one to initiate the other flame. wait till the end. 45 minutes are up You have 2 pieces of rope, each of which burns from one end to the other in 30 minutes (no matter which end is lit). If different pieces touch, the flame will transfer from one to the other at the point at which the burn rate consumes the first rope to its point of contact with the second rope. The only thing we know about the second rope is that it will burn in 30 minutes if ignited from one end. There is no assurance the second rope will ignite, or burn at the stated rate, if an end is not made to point of contact. do you want to buy saints jerseys,vikings jerseys? depends on what the ropes are made of @eaasy you can assume that the second rope with burn at the same rate if lit from the middle, as the rope burns a set amount of time from either end. If Point A to Point B is the same as Point B to Point A, igniting from the center would cause the flame to finishing burning Point A AND point B at the same time. As for ignition, you have a point. There is no assurance that the first rope does not have a prolonged burn rate at the ends and an accelerated burn rate in the center. Therefore the second rope could have ignited before the first rope finishing burning (at any point before the 30 minute limit) which would make timing 45 minutes improbable. Lay one down, and have the second one touch the first rope perpendicularly at the midpoint. Light the first one, when it gets to the midpoint (15 minutes), the second will start burning. When the second one extinguishing you have 45 minutes. T. Simple, quick, walk away and do 45 minutes' work where you can still see light from the flame. Both ends will finish burning at the same time if environmental conditions are consistent. LAY THE TWO ROPES WHERE THE SECOND ROPE IS TOUCHING ONE END TO THE MIDDLE OF THE FIRST ROPE. IT SHOULD TAKE 15 MINUTES TO START THE SECOND ROPE AND THEN ANOTHER 30 TO COMPLETLY FINISH BURNING SO THIS IS 15+30=45 Show More Responses lay ropes end to end, to make one long length, when first length ignites the end of the second length, touch the last remaining end to it and let the flames meet somewhere in the middle. That way each flame will travel in the correct direction, are considered to be burning end to end, without ambiguously being lighted in the middle and hoping the direction will be as desired.... since it takes 30 minutes end to end, then to ignite both ends of the second rope will draw a 15 minute interval no matter what the burn rate is per divided section, thank you and I will accept $150 K per year and 30 days vacation time yearly as well... I had no idea that rope burning was so lucrative a career field... and I want my own rest room. it all depends on what kind of match you have. They said you have one match (no book or box) so if it's not a strike anywhere match then you're screwed. However, if it is then make the T formation... The vertical rope burns 30m then the horizontal burns both directions for 15. No loops, circles or folding required :-) burn A at the two ends will give you 15 min, and when finish A, then burn B next. Lay the map in a T formation, light two ends of the horizontal rope with the match. when the flames meet in the middle in 15 minutes they will light the second rope which is perpendicular to (and touching) the first rope. That rope will take 30 minutes to burn. Hence, 15 plus 30 = 45 minutes. burn A at the two ends will give you 15 min, and when finish A, then burn B next burn one rope, wait till it gets to the half way point, then you transfer the first one to the second one to initiate the other flame. wait till the end. 45 minutes are up Helpful Answer? Yes | No Lay the two ropes in a "T" shape. Burn the one rope at the bottom end of the "T". It will take 30 mins for the flame to go through first rope, and when it reach the other end, transfering the flame onto the second rope right at the middle with the flame move towards both directions, taking 15 mins to completely burn out. This is a silly riddle.... because we're not given the property that the rope can bend, the best formation for the two ropes is to lay them in the "+" formation that everyone got. However, no one mentioned burning the rope at the intersection of the two ropes, ropes will burn in 15 minutes. Also, there isn't anything saying you can't light the ropes more than once with one match (assuming you have the ability to light the match, as someone already pointed out as a significant problem), in that case, you could burn the ropes up in less than a minute. If the rope can bend, just bundle the ropes up into a ball and light the rope ball on fire... it take 1.3 seconds to burn the ball if you create the most efficient weave... true story, I was there. But of course, if you wanted to make the most efficient use of your time (e.g., if you're lazy), you can just crumple the ropes up together, drop the heap of rope on the ground, and throw the lit match on the pile and be done with riddle (and the ropes... and the match). I agree with a couple people here. In this you cant assume the rope burns uniformly. Therefore loop one rope and put the end of the other so it touches where the ends meet. so you have this C--- light the straight rope, when it burns it'll light the "C" which will burn in half the stated time (15 mins). Just a quick one for all the "T" people, you're wrong... The rope doesn't burn uniformly so you can't measure to choose time. If you could you may as well just cut one of the ropes... Show More Responses Solution: NO YOU CANNOT GUARANTEE 45min. Most likely solution to work: Straight followed by loop. ---O One straight, followed by a loop. Ignite straight first, have it ignite the loop. You ignite the straight, gives you 30 minutes. Loop ignites, both ends may burn at different speeds, but when it finishes it will be 30mn/2. The flame may end anywhere on the loop, not necessarily at the 1/2 way of the rope. Why wouldn't it work: Above, you're assuming the rope burns end to end. If the rope is really non-uniformly burning, you can devise a case where burning on both sides at the same time doesn't make the burn 1/2 the time: For example, the outside burns real fast and the core real slow: no matter where you ignite it, or how many times, it would burn in 30mn. For that case, you could split the rope at their diameter and maybe rig a solution. But likely there can be another counter example that can be built, more and more far fetched. Interviewer will want you to explain the thoughts, non-uniform burn, etc. So this is an opening to check your deductive powers. What's the purpose of such a simple question? To judge how you react and explain yourself? Fold each rope in half & mark them in the middle. Light 1 rope & when it reaches the middle light the other one. When the 2nd rope burns completely you'll be at 45 minutes. no comment Too easy... fold one of the ropes in half end to end with the full rope... viola! There are a couple of answers. It depends how you would interpret the question. "the flame will transfer from one to the other" Assuming no special materials you would have on the ropes. This phrase can be interpreted that THERE CAN ONLY BE ONE FLAME. Thus the flame moves from one to the other and does not multiply i.e you can have more than one rope or section of the rope burning .(If it could the solution is easy-just arrange both ropes end to end into a pentagon shape or do what some people have suggested above). for the 45 mins thing you do the T shape like people above suggested so 15+30 =45. If you assume you HAVE to take 45 mins this is the best way. Assume that an earlier finish is best, the Pentagon would be fast. -When I mean pentagon I mean the 5 pointed star thing you know from the occult.- If there was only one flame which could transfer from one rope to the other without creating multiple flames you would have to ask how fast does the flame transfer and what distance does the flame burn at before being transferred. The reason for this is, if the ropes are lied down next to each other TOUCHING each other then the flame would burn, transfer, burn, transfer etc. this would take 30 mins assuming that there is no time lapse on the transfer(hence my questions above). If you wanted to hit the 45mins like it said in the question just have both ropes lie next to each other but have the second rope start from the middle of the first. So after 15mins the second will burn and the flame from this point the remainder of the first rope(15mins) and the second rope will burn 30 mins. Sorry for the poor spelling . Cheers Take one rope, fold it over so one end touches the other, then cut the rope in half. Place one half of the rope at the end of the second whole rope so their ends are touching. Then light either end for 45 minutes of burn. I can't assume rope properties, but nothing says I can't cut it in half. Fold Rope A in half. Lay it down next to Rope B, which is not folded at all. Light Rope B. Reminds me of some of the stupid questions in the Corvirtus test. I took one recently and felt like a 3rd grader. I'm Schmart, I swer. Make a plus sign the the ropes. Light any one end. 15 mins to get get to center, 30 to burn the other rope. Show More Responses Must be a crew of techies answering this question. The obvious answer is to look at a clock. lay both pieces of rope down so that end of rope A touches the end rope rope B light the end of either rope, after 30min have passed the flame will transfer to the other rope,when the rope is half burn 45 total min will have passed. so yes you can time 45min. 45 minutes is easy. I would rather have an hour of light. Tie the ropes together, making one long rope. Light one end and get 1 hour. The Question is "Given only 1 match, can you time 45 minutes?". Option 1. You have a timing device and are allowed to use it - no prohibition stated in setup or question - of course you can "time 45 min" to the precision of your timing device. Option 2. We know: Ignition can occur at either end. From reaction start to reaction end of each rope takes 30min. We can not assume that the rope burns evenly, can be bent, lit up other than the ends or even transmit the flame to the outside of the rope (Think trapped chemical burn in a tube). Therefore we can NOT build a timing device. Put one rope in a straight line, bend the second rope into an O shape (with both ends touching one end of the first rope), when the first rope reaches its end, 30 minutes will have passed, and ignite the second rope. The second rope, which has both of its ends ignited at the same time, will meet at its center, timing 15 more minutes have passed. -> ///////////O Lay down both ropes evenly side by side. Slide one rope down 1/2 the length of the other then light one of the ends. Make a "T" with the ropes. 1 rope burns in 30 min, that rope is touching the middle of the second rope, and with two equal halfs(30/2) it should burn in 15 mins. ----------- -------------, then push them together First of all, the question is "Given 1 match, can you time 45 mins?"... well you can stand there with a match in your hand and time 45 mins with any stopwatch. Or is the question really can you time 45 mins using that match? Then using the match to create a shadow..... hem hem maybe not. Let assume the question was meant to be "can you burn both ropes in 45 mins?"... well it doesn't say anywhere that the match can only light one rope. I've lit many birthday cakes in my days and I promise that only one match can light a full array of candles. So if the ropes burn in 30 mins. and you light both of them with the one match then yes; the burning of the ropes should be done under 45 minutes. But then again.... maybe the question was "can you burn both ropes in EXACTLY 45 minutes?" Now the real answer I think is that the question need to be more clear :) Light one of the ropes from one side only. when it burns out completely (30 mins) light the second rope from BOTH sides. that will double the rate at which it burns, making it completely burnt out in 15 mins. Total 45 min Show More Responses ***CORRECTION*** didn't realize the "one match only" make a loop and a long rope running out of it (like a key figure) light the loose end of the standing rope. it will burn in 30 min. When it reaches the end it will ignite both sides of the other rope, doubling the rate at which it burns (i.e. it will burn to completion in 15 min only) that's a total of 45 min. Keep the first rope straight, and the two tips of second rope touching one end of first rope. Now lit the other end first rope. So first rope takes 30 min to burn and transmit fire to two ends of second rope which will take 15 min to burn. So total of 30+15= 45 min The answer is simple... Make a sundial with the match and the rope. Can Keep the ropes in this fashion----------》 《--------- And fire dem with opposite side burning. Now when both fire meet it wil be 15 mints...nw both have 15 mints remaining now bur first remain rope which will take 15 mints more and den burn second remaining rope which will take another 15 mints..so total 45 mints..isn't it simple ..;) The question does not state that the items in the question are required to provide the answer so... Take note of your start time. Take the first length of rope and lay it next to the match. Then, carefully inspect the second length of rope for any defects. If none are found, or even if there are defects present, place the rope on the ground in a straight line facing north to south. Place the first length of rope, which is tired to the match, approximately 5 feet to the north of the second length of rope. **Warning: This step requires quick action on your part** While the match is burning, tie the first length of rope to the match. Take the second length of rope and touch the north end to the match while it is still lit. Grasp the second length of rope in your left hand and spin 360 degrees counter clockwise and throw it as far as you can. Now go have a beer and keep an eye on your watch to see when the 45 minute timeframe has finished. |

### Software Engineer at Google was asked...

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 Responses exit=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 |

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 temp oh 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 Responses do 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...

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 NO 4 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 Responses obviously without return NO at the end |

### Front End Software Engineer at Yahoo was asked...

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 Responses Since 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...

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 Responses int 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! |

### Software Development Engineer at Yahoo was asked...

None.. All questions were simple. Reverse a linked list, find a duplicate node in the linked list, etc 4 AnswersHow do you find duplicate? Using bitmaps or hash right? reversing a linked list is O(n) if you are allowed to keep a second linked list with the opposite data. Finding a duplicate node in a linked list can be done using a Hash, yes, or bitmaps (a little more work). But ideally, I think I would iterate the tree and store them into a heap of some sort and then pop the top of the heap and have the answer. This is O(n) to iterate and O(log n) to insert into the heap. If you were to use a Hash you would have to populate the hash, and then iterate over the hash to find the largest key->value pair (and iteration of a Hash is O(n)). Thus, Time to iterate linked list = T_LL = O(n) Time to iterate hash = T_H = O(n) Time to insert to heap = T_Heap = O(log n) and Time to access root node (max occurrences in Heap) = T_H_Access = O(1) Clearly T_LL + T_H > T_Heap + T_H_Access I am sure more ways exist! This just illustrates the work for 2 ways. ummm it's much simpler than that Mike. Reverse the list: public void reverse(final List list) { Node prev = null; Node next = list.head; Node n = list.head; while(next != null) { next = n.next; n.next = prev; prev = n; n = next; } } as you can see, you don't need a second list. this will run in O(n) time. Also for finding the duplicate. Just use a hash map. on average you get O(1) for insertion into the map and you don't even need to go through the entire list as the question only asks to find "a" duplicate node. so something like this. public Node findDuplicate(final List list) { final Map map = new HashMap(); for(final Node n : list) { if(map.contains(n)) return n; else map.put(n, n); } } Worst case run the loop n times each contains check worst case O(n) but average should be O(1). So your best case runtime for the whole thing should be O(n), and worst case O(n^2). Show More Responses For Reversing the LinkedList: Push the link list on a stack and pop the stack to create a new linked list |

### Software Engineer - New Grad at Yahoo was asked...

None I could think of, I prepared everything from careercup yahoo questions and programming interviews book. I dint had an offer during the time I was writing this. 1. find right cousin of a given node. 2. simple oop and data structure questions. and lots of simple questions checking my ability to handle things in log(n) complexity. 3. binary search - took me into situation I wrote code in 3 diff, prog. lang's 3 AnswersDid you finally hear from them? I too am waiting for a response from 2 weeks. I did try to call them around 50 times may be and 20 emails..finally the answer was NO. But just might be common sense thing, if the recruiter hasnt contacted, then the candidate was rejected. I hope I dint even believe my common sense, and dragged the situation. However the situation will not always be same for everyone. Good luck Samir, Hope you have a chance at Yahoo Thanks Vakshu. After seeing your response, I called up the HR (already sent a couple of emails). She says "I was good at the interviews. But the position was filled with another candidate. And they are finding another position for me." God knows. Whats the matter. If the position was already filled, why did they call me then? They should really stop playing with the sentiments of candidates. All of us prepare so hard to finally know that we are being turned down. I am not saying rejecting a candidate is hurting him/her. But delaying the result certainly hurts. I am no more hopeful !!! |

which is hard to fix -- setup violation or hold violation? And why? 4 AnswersI answered setup, then they asked again how to fix the setup violation. Should be the hold time violation. Setup time violation can be solved by increasing the time period; however, hold time violation should be solved by inserting delay into the timing path carefully I think it depends on which stage the problem is detected. If after tape out, it's absolutely hold time because you cannot easily change the logic of chip. But if it is still in RTL coding stage, hold time may be easily fixed by adding some buffers. Show More Responses At any stage of the design, it is the setup time violation that is difficult to fix. Hold time violations can be fixed easily by adding buffers and this is also automatically done by the software. Options to fix setup time violation are: 1. Play with the positioning of the gates to reduce the routing in between the gates. This reduces the parasitic capacitance encountered by the path and speeds it up. It is pure place and route exercise and is the most preferred solution. 2. Upsize the registers at the input stage to the offending path. This adds silicon area to the initial stages of the offending path and results in additional power consumption, but is an easy fix. 3. Re-design the logic between register stages. This is more easily done during the earlier stages of the design, but is a clean solution. 4. Nand-ize the logic path. A nand gate is faster and a better driver than a nor gate. This can result in more gates changing in the path, hence more floorplan and routing changes, but actually could result in less buffer stages, hence silicon area and less power consumption. 5. Increase the time period of the clock for that offending path by adding delay to the clock of the following register stage. This will affect the timing of the following register stage, affect the routing of the clocks, etc. Since this affects more signals and paths, this is less preferred. 6. Remove a register stage, in effect combining the data path with its following stage. 7. Increase the clock time period for the larger block or the entire chip. |

**1**–

**10**of

**1,333**Interview Questions

## See Interview Questions for Similar Jobs

- Mechanical Engineer
- Software Engineer
- Hardware Engineer
- Engineer
- Engineering
- Mechanical Design Engineer
- Design Engineer
- Intern
- Senior Software Engineer
- Product Designer
- Project Manager
- Product Manager
- Product Engineer
- Product Development Engineer
- Senior Product Design Engineer
- Manufacturing Engineer
- Senior Mechanical Engineer
- Industrial Designer
- Program Manager
- Engineering Manager