Software engineer Interview Questions in Sunnyvale, CA | Glassdoor

# Software engineer Interview Questions in Sunnyvale, CA

Software engineers write programs to design and develop computer software. Interviews are highly technical, so come ready to work through coding problems and math brainteasers. The specific questions you are asked will depend on what type of programming position you are looking for. Try researching a specific software discipline such as web development, application development, or system development.

## Top Interview Questions

Sort: RelevancePopular Date

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

### 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.

Apr 4, 2017
 1. You have n doors in a row that are all initially closed. You make n passes by the doors starting with the first door every time. The first time through you visit every door and toggle the door (if the door is closed, you open it, if its open, you close it). the second time you only visit every 2nd door (door #2, #4, #6. third pass you toggle 3rd, 6th, 9th door. What state are the doors in after the last pass? which doors are open ? 7 AnswersEvery 3rd door, starting with the first is open if you make 3 passes.Every square numbered (door # 1,4,9,16...) will be open and the rest closed. For a door to be open you need odd number of factors.Show More Responsesall primes and numbers divisible by both 2 and 3 are openfunction Door(idx) { this.idx = idx; this.state = 0; } Door.prototype = { state() { return this.state; }, open() { return this.state = 1; }, close() { return this.state = 0; }, toggle() { return this.state ? this.close() : this.open(); } }; function buildDoors(n) { const funDoors = []; for (let i = 1; i ((1 + index) % i === 0)) .map(door => door.toggle()); } return doors; } const doorFun = builder => count => passDoors(builder(count)).filter((door) => door.state); console.log(doorFun(buildDoors)(9));All prime number doors will be open ( 1,3,7,11,13 ... ) One or more comments have been removed. Please see our Community Guidelines or Terms of Service for more information.

### 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.

Jun 17, 2018

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

Jul 1, 2009
 why should i not hire you4 AnswersIf I honestly thought you shouldn't hire me, I wouldn't waste your time or mine coming to this interview. I believe I am not only qualified for this position, but I will become a proactive asset towards building the company's future.Because people might thought a great candidate would request a great amount of salary.I will tirelessly work to the bone and ensure the quality of work is at my highest abilities. This may, unfortunately, cause other employee's to feel threatened if they are not team players. I am highly motivated and will work to bettering my career and moving up in the world of technology.Show More ResponsesIf you're looking for a lazy, stupid person who is not a team player or works hard. Then you shouldn't hire me.

### 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

### Software Engineer at Amazon was asked...

Dec 18, 2015
 There are many conference room at Amazon, your manager want you to book a conference room for a meeting. The number of people and time is given. Please return a list of rooms which are available at that time and have enough capacity.4 AnswersCreate a Room class, DateNode class, and Building class. The building contains a list of Rooms and a Room has a list of DateNodes which are already booked by others (the dates are sorted respect to startTime attribute of DateNode). I first check the capacity of rooms, if it has enough space, I check the list of dates one by one and determine if I can book the room or not.The question is not clear in terms of how reservation times for all the conference rooms are given?If you have a list of rooms we know that there wont be a conflict so you could hash timestamp and create a list of hash of len number of rooms in that way you just have to go through each room and check for specific hash as you are looking for a specific time slotShow More ResponsesRoom class with String RoomId, int capacity and boolean booked. Create a matrix of 1-24 hours with 15 or 30 minute intervals on X and roomId's on Y. Arrange room objects in the matrix based on availability. If booked == true, remove object. Else, add it to the matrix. Every search should look for room object for a time slot then check capacity ==