Softwareentwickler Interview Questions


Softwareentwickler interview questions shared by candidates

Top Interview Questions

Sort: Relevance|Popular|Date
Software Engineer was asked...June 19, 2012

You have a 100 coins laying flat on a table, each with a head side and a tail side. 10 of them are heads up, 90 are tails up. You can't feel, see or in any other way find out which side is up. Split the coins into two piles such that there are the same number of heads in each pile.

36 Answers

Split into two piles, one with 90 coins and the other with 10. Flip over every coin in the pile with 10 coins. Less

Pick 10 coins from the original 100 and put them in a separate pile. Then flip those 10 coins over. The two piles are now guaranteed to have the same number of heads. For a general solution of N heads and a total of M coins: 1.) Pick any N coins out of the original group and form a second pile. 2.) Flip the new pile of N coins over. Done. Example (N=2, M=6): Original group is HHTTTT (mixed randomly). Pick any two of these and flip them over. There are only three possible scenarios: 1: The two coins you picked are both tails. New groups are {HHTT} {TT} and when you flip the 2nd group you have {HHTT} and {HH}. 2.) The two coins you picked consist of one head and one tail. New groups are {HTTT} and {HT} and when you flip the 2nd group you have {HTTT} and {TH}. 3.) The two coins you picked are both heads. New groups are {TTTT} and {HH} and when you flip the 2nd group you have {TTTT} and {TT}. Less

reading these answers is such a confidence builder.

Show More Responses
Bloomberg L.P.

An array of 99 elements contains integers from 1 to 100 with one missing element. Find the missing element.

20 Answers

1. calculate the sum of elements in array say SUM 2. sum of numbers 1 to 100 is(n* (n+1))/2 = 5050 when n==100 3. missing element is (5050-SUM) Less

Sum them and then subtract them from 5050. In general, if an array of size n - 1 elements has unique elements from 1 to n, then the missing element can be found by subtracting the sum of the elements in the array from sum(1 ... n) = n * (n + 1) / 2. Alternately, one could use a boolean array of length n with all values set to false and then for each value, set array[val - 1] to true. To find the missing value, scan through the array and find the index which is set to false. Return index + 1. This requires O(n) memory and two passes over an O(n) array (instead of constant memory and one pass), but has the advantage of actually allowing you to verify whether or not the input was well formed. Less

Read the question. Here are the steps to solve it: 1) find the sum of integers 1 to 100 2) subtract the sum of the 99 members of your set 3) the result is your missing element! Very satisfying! Less

Show More Responses

Write some pseudo code to raise a number to a power.

11 Answers

int raise(num, power){ if(power==0) return 1; if(power==1) return num; return(raise(num, power-1)*num); } Less

small mistake function power(x, n) { if n == 1 return x; // Even numbers else if (n%2 == 0) return square( power (x, n/2)); // Odd numbers else return power(x, n-1) * x; } Less

double Power(int x, int y) { double ret = 1; double power = x; while (y > 0) { if (y & 1) { ret *= power; } power *= power; y >>= 1; } return ret; } Less

Show More Responses
Expedia Group

Describe and code an algorithm that returns the first duplicate character in a string?

11 Answers

first clarify if it is ASCII or UNICODE string For ASCII, create BOOL checkArray [128] = {false}; walk the string and update the index of checkArray based of the character. for (int index=0;index< strlen(str); index++) { if (checkArray[str[index]] == true) { printf (str[index]); return; } else { checkArray[str[index]] = true; } } Less

for (int i=0;i

public static in findDuplicateChar(String s) { if (s == null) return -1; char[] characters = s.toCharArray(); Map charsMap = HashMap(); for ( int index = 0; index < characters.length; index++ ) { // insert the character into the map. // returns null for a new entry // returns the index if it previously if it existed Integer initialOccurence = charsMap.put(characters[index], index); if ( initialOccurence != null) { return initialOccurance; } //there where no characters that where duplicates return -1; } } Less

Show More Responses
J.P. Morgan

How do you approach situations where multiple influential employees have different (and possibly hidden) agendas.

10 Answers

Testimony By Lizzy Desler. How to get your ex back fast! I was hurt and heart broken when a very big problem occurred in my marriage seven months ago, between me and my husband . so terrible that he took the case to court for a divorce. he said that he never wanted to stay with me again,and that he didn't love me anymore. So he packed out of the house and made me and my children passed through severe pain. I tried all my possible means to get him back, after much begging, but all to no avail. and he confirmed it that he has made his decision, and he never wanted to see me again. So on one evening, as i was coming back from work, i met an old friend of mine who asked of my husband .So i explained every thing to him, so he told me that the only way i can get my husband back, is to visit a priest, because it has really worked for him too. So i never believed in spell, but i had no other choice, than to follow his advice. Then he gave me the Email address of the priest whom he visited. Pristbacasim2000@gmail. com. So the next morning, i sent a mail to the address he gave to me, and the priest assured me that i will get my husband back the next day. What an amazing statement!! I never believed, so he spoke with me, and told me everything that i need to do. Then the next morning, So surprisingly, my husband who didn't call me for the past 7 months, gave me a call to inform me that he was coming back. So Amazing!! So that was how he came back that same day, with lots of love and joy, and he apologized for his mistake, and for the pain he caused me and my children. Then from that day, our relationship was now stronger than how it were before, by the help of a priest. So, i will advice you out there if you have any problem contact Priestbacasim, i give you 100% guarantee that he will help you.. Email him at: Pristbacasim2000@gmail. com or call +2348144258822 / whatssapp. Less

I completely trusted Dr Paul totally from the time I spoke with him during the period my husband Left me after11 years of our marriage, He started the spell work on my husband, and gave me so much assurance and guaranteed me that he was going to bring my husband back to my feet in just 48 hours of the spell casting. I was so confident in his work and just as he said in the beginning, my husband is finally back to me again, yes he is back with all his hearts, Love, care, emotions and flowers and things are better now. I would have no hesitation to recommend this powerful spell caster to anybody who is in need of help.. E-mail; astoriashrine @ gmail com Less

it's almost christmas and you haven't gotten your lover back or you need a man or woman so desperately, or you need your ex back do not worry my daughter/son the great spiritualist from africa is at your disposal were the seven powers of the world is located the great power of the benin kingdom is here contact me now at Gmail: drbabatundelovespelltemple@gmail.comwhatsapp: 07064669209 do not worry my child many spiritualist may have failed you Dr babatunde is here for you the great Ifa the great afoshe and love master remember love conquers all we also help for other services e.g you need a child or you are troubled by someone or you need a solution for a court etc bring your problem today and it shall be solved remember a new year is coming solve all your problems today once again our whatsapp contact is WHATSAPP: 07064669209 COME AND YOUR PROBLEM WILL BE SOLVED Less

Show More Responses

In a given sorted array of integers remove all the duplicates.

8 Answers

The array is already sorted, no need for a set. example: 2,2,5,7,7,8,9 Just keep tracking the current and previous and the index of the last none repeated element when found a difference copy the element to the last none repeated index + one and update current and previous, no extra space and it will run in O(n) Less

public RemoveDuplicates() { int[] ip = { 1, 2, 2, 4, 5, 5, 8, 9, 10, 11, 11, 12 }; int[] op = new int[ip.Length - 1]; int j = 0, i = 0; ; for (i = 1; i <= ip.Length - 1; i++) { if (ip[i - 1] != ip[i]) { op[j] = ip[i - 1]; j++; } } if (ip[ip.Length - 1] != ip[ip.Length - 2]) op[j] = ip[ip.Length - 1]; int xxx = 0; } Less

public static void removedup(int[] input){ int count =1; int i=0; for( ;i Less

Show More Responses

Given an array of numbers, replace each number with the product of all the numbers in the array except the number itself *without* using division.

7 Answers

O(size of array) time & space: First, realize that saying the element should be the product of all other numbers is like saying it is the product of all the numbers to the left, times the product of all the numbers to the right. This is the main idea. Call the original array A, with n elements. Index it with C notation, i.e. from A[0] to A[n - 1]. Create a new array B, also with n elements (can be uninitialized). Then, do this: Accumulator = 1 For i = 0 to n - 2: Accumulator *= A[i] B[i + 1] = Accumulator Accumulator = 1 For i = n - 1 down to 1: Accumulator *= A[i] B[i - 1] *= Accumulator Replace A with B It traverses A twice and executes 2n multiplicates, hence O(n) time It creates an array B with the same size as A, hence O(n) temporary space Less

Create two more arrays. One array contains the products of the elements going upward. That is, B[0] = A[0], B[1] = A[0] * A[1], B[2] = B[1] * A[2], and so on. The other array contains the products of the elements going down. That is, C[n] = A[n], C[n-1] = A[n] * A[n-1], and so on. Now A[i] is simply B[i-1] * C[i+1]. Less

Here are my 2 cents to do this in memory without creating temporary arrays. The simple solution , if division was allowed, was multiple all the elements of the array i.e. tolal = A[0]*A[1]]*....*A[n-1] now take a loop of array and update element i with A[i] = toal/A[i] Since division is not allowed we have to simulate it. If we say X*Y = Z, it means if X is added Y times it is equal to Z e.g. 2*3 = 6, which also means 2+2+2 = 6. This can be used in reverse to find how mach times X is added to get Z. Here is my C solution, which take pointer to array head A[0] and size of array as input void ArrayMult(int *A, int size) { int total= 1; for(int i=0; i< size; ++i) total *= A[i]; for(int i=0; i< size; ++i) { int temp = total; int cnt = 0; while(temp) { temp -=A[i]; cnt++; } A[i] = cnt; } } Speed in O(n) and space is O(1) Less

Show More Responses

Suppose you have a matrix of numbers. How can you easily compute the sum of any rectangle (i.e. a range [row_start, row_end, col_start, col_end]) of those numbers? How would you code this?

7 Answers

Compute the sum of the rectangles, for all i,j, bounded by (i,j), (i,m), (n,j), (n,m), where (n,m) is the size of the matrix M. Call that sum s(i,j). You can calculate s(i,j) by dynamic programming: s(i,j) = M(i,j) + s(i+1,j) + s(i,j+1) - s(i+1,j+1). And the sum of any rectangle can be computed from s(i,j). Less


The answer is already popular in computer vision fields!! It is called integral imaging. See this page Less

Show More Responses
FDM Group

How many unique handshakes if each person in a group of 10 give handshakes out to each and every other individual. (a) 100 (b) 50 (c) 45 (d) 20 (e) 10

5 Answers

true, or 9+8+7+...+2+1

45. Imagine it as a polygon of side 10. Or draw out triangle, square, pentagon, and see the pattern yourself, if you don't know the algorithm. Less

None of those answers are correct. The follow-up question should be are we assuming that each person is only using 1 hand? For example, if everyone is only giving handshakes left to left, or left to right or right to right or right to left? Granted left to right and right to left would be awkward. Less

Show More Responses

What sort would you use if you required tight max time bounds and wanted highly regular performance.

6 Answers

Merge sort and heapsort are always guaranteed to be n*log(n). Quicksort is usually faster on the average but can be as bad as O(n^2), although with very low probability. Heapsort also does it sorting in-place, without needing an extra buffer, like mergesort. Lastly, heapsort is much easier to implement and understand than balancing trees mentioned by earlier posts. Less

That is so say, a "Balanced Tree Sort" is guaranteed to be O(n log n) always.

for something like this you generally want bubble sort or insertion sort. It's not about being fast it's about being consistent. Make it do exactly the same thing every time. Less

Show More Responses
Viewing 1 - 10 of 446,620 Interview Questions