Software Engineer II Interview Questions
Software engineer ii interview questions shared by candidates
Top Interview Questions
Software Engineer II at Redbox was asked...
How many people flew out of Chicago last year? 66 AnswersYou are obviously not supposed to know the answer to this question. It is more of a way to gauge how you would determine the scope of a problem and work your way from no knowledge to being able to put together a solution to figure it out. Actually the answer is zero. Plans fly, people don't. oops - typo - Planes fly, people don't Show More Responses Roughly as many who flew into Chicago. My estimate off the top of my head is 30 planes/hr x 24 hr/day x 365 days/yr x 180 people/plane (avg) = 47M and change. Actual for 2014, Domestic and International, is 70M. This is Passenger Volume so # leaving is 35M. Humans don't fly. Considering that humans fly after sitting in plane, I say it is 1 million. To check it, verify the database yourself. None, . Airplanes fly people ride People can not fly, however planes can. I don't know, but if you gave me some time on the internet, I could find out Chicago is one of the busiest airports. There maybe 1000 flights flying out everyday. 50 ppl in each flight. So 50,000 none. people can't fly I believe the answer is "I don't know" (Unless you do know.) There is a growing idea that businesses need people who are willing to admit that they don't know the answer to something and will admit that without hesitation or making something up. If you aren't comfortable just leaving it at "I don't know" you could explain how you would go about finding the answer. Show More Responses What is the relevance of the question to the job being applied for? Under their own power: zero. via airplane: 139,345,887.5 people. Just one...but he was sucked into an airplane's engine in-flight and no one will ever know how he accomplished human flight. Half of the people who had tickets. Chicago weather sucks!!! :) All of them did, they couldn't find any good movies to rent from RedBox. None unless "Chicagoans" have wings. Flying's the easy part. Anything can fly if you put a big enough engine on it. So, maybe 1 or 2? Doubt any are still alive, though. The landing is the tricky part. Unless I missed out on that Fox News Special. I'd have to give a resounding "ZERO!" People don't fly! Definitely not all of them... I have no idea. I guess the interview thing to say would be "I can find out for you though" but honestly, isn't my time best spent on something else? Show More Responses This is not an oddball question at all but a classic in job interviews for aspiring consultants. The question is testing your problem solving skills rather than your knowledge and the answer is of no real importance as long as your way of getting to it is conclusive. The obvious "people don't fly, planes do" may be good for a quick laugh but unless you follow up with a real answer, you're out. Since the question was from an interview for a software engineer, the right answer is "give me your name, email address, and office extension and we'll open a help ticket"; then do not open a help ticket and forget the call ever happened If it's February, all of them. I don't know, but if it's necessary for me to know this, I can certainly find out. Why is this important for me to know? 1.5 as many that flew in Zero. People cannot fly. I am not sure that data exists because of private aircraft also coming and going. If the FAA or airport authorities have that data, combined with passenger data, I could probably research it and find out. Do parachutist count too? As many as those who flew in Chicago Show More Responses Well, don't ask the airlines. No one knows what the hell's going on at ORD I'd guess: 4 minute FAA separation mandate 737 the most common = 120 ppl Hours of operation = 6am-12pm (abatement) 365 days 6 runways (double triangle for busy airports) 6 runways x ((18h x 60min/hr)/4min per plane) x 120 ppl x 365 days = 70.956M ppl total. As others said, half those are flying out, so 35.478M ppl But I'm an aviation nut, so that's more than the average bear. Google for 1st estimate and then dig in deeper if this would be a significant information to a Project. Do witches count as people? Oh wait, witches don't fly. Brooms fly. The same number of boarding passes given out Why the crap would we have to estimate it when the information would be available from secondary sources....google it Was the Birdman movie set in Chicago? Zero. As many as had reached to Chicago through airplanes. Show More Responses Everyone who boarded a departing flight. For the folks doing the math: there's more than one airport in Chicago. Adjust accordingly. None, people are incapable of flying. None people are incapable of flying. Only one, I can even tell the name to you on my first day. Yea, none. The calculation is a bit tricky, if you really want to know it: It is relatively proportional to the number of Bags (luggage) carried out of Chicago. Please provide me the database, I would come up with an answer. Note: For precise number you need to also include the handbag. Regards, Abhi Besides Superman probably nobody else. None. People can't fly. Zero. People can't fly...no wings. Show More Responses Zero. People can't fly...no wings People can't fly as many people who booked flights through Chicago. None. Technically, there are no airports "in" Chicago. They're in the suburbs. One guy : RKELLY. He is the only human being who believes he can fly. Approximately the same number that flew in "The number of people who flew out of Chicago" is a true answer, albeit a tautological one. It requires no specifics and takes into account not only the zero ("people don't fly") answer but many of the other responses above as well, some of which may be off a few degrees (for example, even people who had boarding passes and got on board might not actually have completed their flight, and not everyone who flies in flies out, etc.). This tautological answer, though, because the context is an interview, is likely to be perceived as flip and would probably get the answerer lumped in with the people who answer zero—the "if the person says zero, he or she is automatically out of the running" scenario mentioned above. Although to use a tautology or to answer "zero" probably won't succeed if done directly, such things can be embedded within one or more linguistic frames, including hypotheticals—ifs. ("If you wanted a tautological answer, I could say XYZ" or "Assuming you're not being literal about people flying and you're interested in finding out ABC about me, then XYZ.") Another way of approaching the question—a way that in fact is a demonstration of your strategy for relating to questions, an answer in itself—is to ask a question in return (such as one that probes for more detail—"Does that include private planes as well as commercial carriers, and blimps, helicopters, and so on?"), which invisibly begins to shift the dynamic of the interview (now you're the one asking the questions). Perhaps a better-quality question than asking for details about the content of the question would be to notch it up a level and ask the questioner something that seeks to discern his or her underlying purpose in asking the question. By doing so, the sterile, impersonal nature of the question is transcended and a personal exchange comes into play between interviewer and interviewee-cum-interviewer. The question you invent is up to you—how brilliant can you be at having the other person be brilliant? No one flew out of Chicago last year, because people do not have wings. No one. People do not have wings. I would google it. Show More Responses Those people flew out of chicago who have bought air-plane ticket. They all did. With Air Canada, twice as many as their luggage. One or more comments have been removed. |
Determine whether the binary representation of a number if a palindrome or not, code it on a white board. 13 AnswersThis was the first question I was asked and is considered a warm up. anon.. would this work for a number like 17 (10001)? Show More Responses bool checkPalindrome(unsigned int n) { int m = n, k =0; bool ret = false; while(m!=0) { int i = 1; i = i & m; k = k > 1; } if((k^n)==0) { cout<<"Palindrome"< I have a simple solution. Reverse the bits one by one and test equality of the two resulting numbers. (Matlab code) function [r] = isPalindrome(a) n = a; m = 0; while(n>0) m = bitshift(m, 1); m = m + mod(n, 2); n = bitshift(n, -1); end r = (m==a); end public static boolean isPalindrome(int n) { int nb = 0, nl=n; while(nl>0) { nb=(nb>1; } return nb==n; } @john/catalin4ever, i think it'll fail because it doesn't concat the 0s. For example: if the input is 0110, then after execution "nb" becomes to 0011. this is because of the condition: while(nl>0) Ask interviewer if they want the MSB that is a 1 to dictate the bit range to check, have it given as a parameter, or assume sizeof(T)*8 perhaps. Little details and extras like this can make a difference to them. public static bool CheckPalindrome(uint n) { return CheckPalindrome(n, 0); } unsafe public static bool CheckPalindrome(uint n, int bits) { if (bits == 0) { // Determine bits to check as the MSB having a 1 uint temp = n; while (temp != 0) { ++bits; temp >>= 1; } } uint m1 = (uint)1 > 1; i > 0; --i) { if (((n & m1) != 0) ^ ((n & m2) != 0)) { return false; } m1 >>= 1; m2 <<= 1; } return true; } Examples: BitOps.CheckPalindrome(17, 0) is true BitOps.CheckPalindrome(17, 8) is false BitOps.CheckPalindrome(0xABD5, 0) is true BitOps.CheckPalindrome(0xABD5, 16) is true BitOps.CheckPalindrome(0x5BDA, 0) is false BitOps.CheckPalindrome(0x5BDA, 16) is true string binary; int start=0, int end= binary.length -1; while(start < end) { if (binary[start] == binary[end]) { start ++; end- -; } else return false; } return true; int isPalindrome( int num ) { int x = num & num; return ( x == num ) ? 1 : 0; } /* function declaration goes here.*/ int isPalin(int orig); int main() { int x = 9; int i = isPalin(x); printf("i = %d \n", i); } int isPalin(int orig) { int copy = orig; static int reversed = 0; while(copy!=0) { reversed >= 1; } return (reversed == orig); We can compare the leftmost and rightmost bits by left shifting and right shifting the bits and also by getting rid of those bits . If the binary number is a palindrome, the left and right bits should be equal. Here is a C# implementation of the above logic static bool IsBinaryPalindrome(byte num) { int i = 0; while (true) { i++; bool right = false, left = false; byte origNo = num; if (((num > i) != origNo) { left = true; //left most bit contains one } num >>= i; //putting the right bit back in its original position origNo = num; if (((num >>= i) << i) != origNo) { right = true; // right most bit contains one } num <<= i; //putting the left bit back in its original position if (left != right) { return false; } if (num == 0 || num == 1) break; } return true; } python one-line need to replace the the 0b >>> str(bin(255).replace('0b',''))==str(bin(255).replace('0b',''))[::-1] True One or more comments have been removed. |
Find k largest/smallest number in a series of numbers. What data-structures will you use? Code it on white board. 6 AnswersFor K smallest number in series you can use a max heap of size k. When you find a new number and it is smaller than root of heap, swap it with root and heapify. @Ajit: What're the initial values of the max heap? What happens to the first value that comes in? Use selection sort for 'max' ( or for 'min') If K > series.length/2 then reverse the criteria- like in stead of looking for 15th highest out of 20 element array - look for (20 -15 =) 5th lowest and so on.... Show More Responses I think there's a cool solution which involves doing a pivot operation (like quicksort) until you have the top/bottom k numbers sorted. It's possible that you can get the top k numbers in a single pass of the array if you happen to choose a good pivot, and in general takes very few passes to find the top k numbers. I coded it up in C a while back: http://privatepaste.com/1f1df9d8f0 You just call select with your list, the min index, max index, and top k numbers, respectively. It can be easily changed to find the min (just reverse the swap condition) @Jordan, I can no longer get at your privatepaste link, so if you see this post I am interested in answers to the following: - since partition sizes are inherently not controllable by your choice of pivot, how do you land on an exactly k-sized partition (or even a k-sized total of the leftmost/rightmost N partitions)? - how do you choose pivots reliably to perform this (if it isn't reliable, then it isn't always a good answer just like pathological inputs for quicksort without randomizing the pivot selecting) - do you still just sort the partition(s) once you reach a k-sized set? I assume they want them in-order. I would just use a heapsort that short-circuits once K elements have been popped from the internal sifting loop, which does minimal processing and returns them in-order (C# example): public void FindKLargest(T[] A, int k) { . Heapify(A); . int end = A.Length - 1; . int k_offset = Math.Max(Math.Min(k, end), 1); . int stop = end - k_offset; . while (end > stop) . { . // Save the root heap item as done . Swap(ref A[0], ref A[end]); . // Separate heap from saved item . end--; . // Re-sift the new root item . SiftDown(A, 0, end); . } . // the K largest entries are now in ascending order at the end of A } One or more comments have been removed. |
None of the questions were unexpected, at least for any candidate applying for this job. I definitely felt I could have answered few questions better. 5 AnswersGeneral QA or a lot of coding related. Thanks QA questions were less more of coding and sql query questions were asked. Hello, could you please tell what kind of algorithms/data structures they asked you. Show More Responses Please share the coding questions Hello, Can you please share how much time did the recruiter take to get to you with an offer? |
Software Engineer II at Blackbaud was asked...
You have 2 jars and 50 black beads and 50 white beads. How many would you put of each color in each jar so that if a bead was randomly selected from both jars, you had the greatest chance they would match? You have to put all of the beads in the jars. 5 Answers1 of either color in the first jar (100% chance to get that color), the rest in the 2nd jar (very close to a 50% chance to get a matching color). If you fill each jar with half black and half white then you will have a 50/50 chance of drawing a match. If you put any more than half of a color in jar number 1, then you will increase your odds of drawing that color from jar 1, but since there will be a smaller number of those beads in jar 2, you will decrease the odds of drawing that color from jar 2. Therefore any configuration other than half of each color in each jar will result in less than 50/50 odds of drawing a match (like in the answer above). As long as the ratio of black beads to white beads is 1:1 in both jars, it doesn't matter. Show More Responses One of each jar This question is too easy |
You have two linked lists that merge at some node. The lists could be billions of nodes long. Find the node where the lists merge in the most optimal time while using a low amount of memory. 5 AnswersIf the lists have a length value, then you should be able to do this pretty simply. If two lists merge, then they have the same terminal node. That means that from the merge node to the end they have the same length. So if you subtract the smaller lists length from the larger you end up with a great starting point to begin searching. you then increment down the lists from that point on to find the node where both lists meet. Above answer is not correct. Its a list so you can only start from the begininning. If its a doubly linked list, yes, you can start at the end (and should), but you cannot start "mid-list". I can think of two ways: 1) traverse from both heads, get two length: long, short traverse again starting from Array1[long-short] and Array2[0], looking for the same pointer O(4n) time, O(1) space 2) use a hash table holds all seen pointers. traverse from both heads O(2n) time, O(n) space Show More Responses Step 1: if the linked lists are not empty, find the length of each linked list. Since they have a common end point, we will get length of common area of the linked lists too. Step 2: find the difference between the length of both list. Start traverse the biggest list till the difference in length between them, provided one of them is bigger than the other. Step 3: now they are at the same remaining length. Traverse both of the together till both are pointing to the same next node.That node is the common node which is the merging point. If there is no such point, then they are not merged. Suppose x nodes before merged node for List1, and y nodes before merged node for List 2, z shared nodes for two Lists. List1.Length = x + z List2.Length = y + z Traverse List1, List2 to get their lengths. List1.Length - List2.Length = x - y Starting traverse at same time from (x-y+1)th nodes of List1, and head of List2 (when x>=y) or Starting traverse at same time from (y-x+1)th nodes of List2, and head of List1 (when x<=y) till they point to the same node, that node is merged node. otherwise, no merged node |
How can you solve n^m efficiently only using +, -, *, /. 4 AnswersThis is one solution that doesn't deal with negative exponents exp(n, m) { if (m == 0) return 1 if (m == 1) return n exp = exp(n, m / 2) if ( isOdd(m) ) exp = exp * n return exp } int f(int n, int m) { if(m==0) return 1; if(m==1) return n; n=n*f(n,(m-1)); return n; } There is no need to solve it recursively. it is pretty simple int calculateExp(int n, int m) { exp = n for (i = 1; i <= m; i++) { exp = exp*n } return exp; } Show More Responses Disadvantage of recursion is the large amount of space on the stack for a large m in this case. |
How would you find a duplicate number in a very large unsorted array of ints. 4 AnswersfindDuplicates(int array[]) { int duplicates[] , index; for (int i=0; ii; j--) { if (array[i] == array[j]) { duplicates[index++] = array[i]; break; } } print duplicates; O(n^2) is the usual naive answer but there are properties that if true can reduce this to O(n) using bit ops: In general, if the given array range can also be generated where the duplicated number you are trying to find gets no special treatment and is included just like all the rest a single time, then you can get the answer this way: set total to 0 foreach (n in given array) xor all n into total foreach (n in generated range) xor all n into total total is your answer This works because all the non-duplicated single entries will cancel out via xor with their single entry from the generated set (since they are all paired) and the duplicated number will have an extra odd entry (since it will have 2 entries already from the given array + 1 from the generated set = 3 entries). And because of course xor is commutative; the order of the xor'ing doesn't matter: 6^6^5^5^4^4 = 0, as does 6^5^4^5^4^6 It is a variation of these problems: - find a missing number in an unsorted array - find an unduplicated number in an unsorted array of duplicates I should have added t the above: Ask the interviewer if the array of N has any special distribution. In particular, for the duplicate question here, ask if the array of N contains [0, N-2] or [1, N-1] values unsorted, in addition to one extra entry duplicated in that set duplicated. Show More Responses [Apologies for multiple posts, I don't see any way to edit a post once made ...] There is also a way to find 2 different numbers instead of just 1 resulting from any of the above variations. If you first do the above xor O(n), your answer is actually A^B since you cannot separate the 2 numbers ... yet. The trick here is to get A and B into different unsorted subarrays, with all the other pairings that self-cancel into either subarray with them (but still in pairs together). That is done by noticing that even though you have no idea what A and B are individually, you do know that since the total is A^B that any 1-bit in the total A^B means that bit is different between A and B. So divide up *all* the numbers based on each having a 0 or 1 in one of those different bits. pseudocode -get the A^B total via the xor O(n) algorithm previously posted -determine as pivot an Nth bit which is different between A and B (any 1-bit in the A^B total) -run through all the same numbers again, but this pass accumulate xor's into an even or odd total depending on the chosen bit - the final answer for A and B will be the 2 accumulated totals Complexity: 2 O(n) which is just O(n) |
How would you reverse a linked list in Java? 5 AnswersList.reverse() First answer is incorrect (no such method). 2nd answer is correct. I've seen this question before where the expected answer is to manipulate the list. Show More Responses public class LinkedListElement { private E _element; private LinkedListElement _next; public LinkedListElement(E element) { _element = element; _next = null; } public LinkedListElement(E element, LinkedListElement next) { _element = element; _next = next; } public E get() { return _element; } public LinkedListElement next() { return _next; } public void setNext(LinkedListElement next) { _next = next; } public static LinkedListElement reverse(LinkedListElement e) { if (e == null) { return null; } LinkedListElement current = e; LinkedListElement next = e.next(); e.setNext(null); while (next != null) { LinkedListElement forward = next.next(); next.setNext(e); e = next; next = forward; } return e; } } public void reverse(ReverseSinglyLinkedList singlyLinkedList){ if(singlyLinkedList.isEmpty()){ return; } Node currentNode = head; Node nextNode = head.nextNode; Node markNode; head.nextNode = null; while(nextNode!=null){ markNode = nextNode.nextNode; nextNode.nextNode = currentNode; currentNode = nextNode; nextNode = markNode; } head = currentNode; } One or more comments have been removed. |
Software Engineer II at Microsoft was asked...
Find middle element in Linked List 4 AnswersSolved it on white board Slow and fast pointers . For each slow move, the fast moves two nodes Show More Responses The key in generic questions like this, is to make sure to cover the fundamentals. There's usually a back-and-forth with the interviewer. Might be worth doing a mock interview with one of the Microsoft Software Engineer II experts on Prepfully? Really helps to get some real-world practice and guidance. prepfully.com/practice-interviews One or more comments have been removed. |
See Interview Questions for Similar Jobs
- Software Engineer
- Senior Software Engineer
- Software Engineer III
- Software Developer
- Software Development Engineer
- Software Engineer I
- Software Development Engineer II
- Staff Software Engineer
- Intern
- Software Engineer Intern
- Senior Software Development Engineer
- Principal Software Engineer
- Director
- Software Engineer IV
- Data Scientist
- Product Manager
- Senior Software Developer
- Engineer
- Software Development Engineer I
- Systems Engineer