Fragen im Bewerbungsgespräch: Software engineer in Region Boulder, Vereinigte Staaten von Amerika | Glassdoor.de

# Fragen im Vorstellungsgespräch: Software engineer in Boulder, Vereinigte Staaten von Amerika

340

Fragen aus Vorstellungsgesprächen für software engineer, von Bewerbern geteilt

## Top Vorstellungsgespräch-Fragen

Sortieren: RelevanzBeliebtheit Datum

### Ein Bewerber für eine Stelle als Senior Software Engineer bei Google wurde gefragt...

24. Apr. 2010
 Intersection of two numerical arrays8 AntwortenAlgorithm and pseudo code* assuming b[] is the longer array quick sort b[] for all items from a[] binary search this item in b[]for above.. O(n log n) + O(n) * O(log n)Mehr Antworten anzeigenI have a O(n) algorithm: 1. Iterate over all the elements of first array a[] and build a dictionary mapping the element value to the index - O(n) 2. Now iterate over all the elements of the second array b[] and for each element that is already present in the dictionary, move the element to a different array that maintains the intersection elements - O(n) 3. Hence the overall complexity is O(n) in time and O(n) for the dictionary and the array to maintain the intersection elements.given arrays of lengths n and m. A simple solution is to sort array n in O(n lg n) and for each item in array m, look for it in sorted n, O(m lg n). So total time = O((m+n)lg n), let array n be the short array. I feel there is a much quicker solution, maybe O(n+m) if we assume integers.Two possible approaches: 1. Sort both arrays and then walk over each array simultaneously until you find all the common entries. This is O(n*logn) to do the sort and then walking over the items is O(n). 2. Walk over first array and insert each item into a hash table. Then search for each item in the hash table. This is O(n) time and O(n) space. If you're doing this a lot with the same sets of data, both algorithms allow you to do the expensive step once for each array and then find the common items in linear time.Simple O(n) solution: public static Integer[] getIntersection(Integer[] a, Integer[] b) { Map countsMap = new HashMap(); for(Integer num : a) { // O(n) time countsMap.merge(num, 1, (x, y) -> y + 1); } List intersection = new LinkedList(); for(Integer num : b) { // O(n) time if(countsMap.containsKey(num)) { // O(1) int count = countsMap.get(num); // O(1) if(count > 0) { intersection.add(num); // O(1) countsMap.put(num, count - 1); // O(1) } } } // Above loops run in O(n) time each. // Total time complexity = O(2n) return intersection.toArray(new Integer[intersection.size()]); }Actually, even conversion of list to array happens in O(n) time. So above solution required O(3n) and not O(2n), Please pardon my mistake.

### Ein Bewerber für eine Stelle als Software Developer bei Google wurde gefragt...

10. Mai 2010
 write an algorithm to divide two numbers using only loops and addition.6 Antwortendelegate the problem to one of the mindless google calculator boys.// I don't get this question.... // Is there any Aha algorithm for solving it, instead of the naive approach? int divide(int dividend, int divisor) int ans=0, partial=0; while(partial+divisorNo, its essentially that asinine. Glad I spent 10 years in the industry and got my PhD to be judged on this algorithm....Mehr Antworten anzeigenI'm not sure a correct answer for this question is going to say, "Hey...Here's the next designer/programmer of Chrome v2"....? WTF?!? public static void main(String[] args){ int divisor = 2; int number = 100; int i = Integer.MAX_VALUE; for (int j = 1; j = number) { System.out.println((j)); break; } } }If they were looking for engineers with dumb ideas like totally destroy their branding by copying Bing's background image function, this would definitely be a good recruiting questions.... like I said before; idiots!int a = 9; int b = 2; int sum = 0; int result = 0; while (sum + b < a) { int term = b; int mult = 1; while (sum + term < a) { result = result + mult; sum = sum + term; term = term + term; mult = mult + mult; } } Print result; It's not hard to realize the calculation time is O(Log(a)) and more precisely C * Log(a/b) <= Time <= C * 2 * Log(a/(2*b))

### Ein Bewerber für eine Stelle als Senior Software Engineer bei Google wurde gefragt...

19. März 2009
 What sort would you use if you required tight max time bounds and wanted highly regular performance.6 AntwortenVector sort.Guaranteed to be O(n log n) performance. No better, no worse.That is so say, a "Balanced Tree Sort" is guaranteed to be O(n log n) always.Mehr Antworten anzeigenMerge 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.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.Use a sorting network. There's some precomputation time, but runtime will be very consistent (the only variability is branch prediction performance)

19. März 2009

### Ein Bewerber für eine Stelle als Senior Software Engineer bei Google wurde gefragt...

24. Apr. 2010
 Hardest things to unit test4 AntwortenSingletons in a runtime environment.my first reaction is "people behavior"multi-threaded code :)Mehr Antworten anzeigenA random number generator.

### Ein Bewerber für eine Stelle als Software Engineer bei Google wurde gefragt...

8. Aug. 2010
 Write a function to return if a number is a palindrome (eg, 113848311)4 AntwortenCount the digits, loop inwards from the outside edges to the center.bool isPaldrome(int n) { int r = 0; for (int num = n; num; num /= 10) r = r * 10 + (num % 10); return r == n; }Explanation: Make another int variable that adds to the end what gets knocked off the input int. Then just return if they match. Sample program flow for 12321 would be: 12321, 0 1232, 1 123, 12 12, 123 1, 1232 0, 12321Mehr Antworten anzeigenThe fastest calculation for this is to only look at half of the digits. Reversing the integer is a bad idea as well because you could overflow the number. The fastest answer in terms of digits is o(n/2) time, but requires o(4) space: bool isPalindrome(int n) { int right = n % 10; int left = n / 10; int power = 1; for(int i = 2; right < left; ++i) { power *= 10; right = right + power * (left % 10); if( (i & 1) && right == left) return true; left = left / 10; } return right == left || left == 0; }

4. Mai 2016

### Ein Bewerber für eine Stelle als Embedded Software Engineer bei Qualcomm wurde gefragt...

20. Feb. 2013
 A brain teaser question where we have to find out 45 minutes with the help of two ropes. Given that one rope burns completely in 1 Hr and the rate or burning is not consistent. 4 AntwortenI assume that both ropes have the same non consistency. If you burn from one end it takes 1H. If you burn it from both ends it takes 1/2 H. To get 1/4 H, burn it from both ends and the point that in the first rope the fires got together.I assume that both ropes have the same non consistency. If you burn from one end it takes 1H. If you burn the first rope from both ends it takes 1/2 H. Immediately after the first rope burnt, burn the second rope from one end and the middle point that fires reached each other in the first rope. To get 1/4 H, burn it from both ends and the point that in the first rope the fires got together.Burn first rope from both ends, and second rope from one end only. When First has completely burned, 30 mins will have passed and second rope will have 30 mins left on it. Now burn second rope, which has burned for 30 mins already, from both ends, this will burn a 30 minute rope at twice speed, making it complete in 15 mins. This will be 45 minutes total.Mehr Antworten anzeigenI've faced same question in ASSIA interview

### Ein Bewerber für eine Stelle als Software Engineer bei Google wurde gefragt...

8. Aug. 2010
 Write a function to return the number with the longest collatz sequence in a given range: int longestCollatz(int lower, int upper);3 AntwortenWikipedia was allowed: http://en.wikipedia.org/wiki/Collatz_conjecture Code is simple. Wrote a recursive function to calculate the length of a given sequence, called it for each number in the range.this was for a phone interview ? first or second ?An optimization is having a cache for already calculate sequence lengths. this is a good idea because whenever you reach the same number the sequence is going to look the same from that point on. In other works, the problems share many common subproblems from which you can reuse solutions.

23. Apr. 2012