Software Developer Interview Questions | Glassdoor.ca

# Software Developer Interview Questions

3,068

Software developer interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

### Intermediate Software Developer at The PEER Group was asked...

Mar. 19, 2009

Jan. 29, 2012
 Write a Java program that takes a 2D bitmap (represented as a 1D array of integers), and reverses it about its vertical axis.4 AnswersI asked the interviewer whether I'm also provided with a width, so that I know how to interpret the data in the 1D bitmap, and he said yes. From a high level, you need a doubly nested for loop: the outer one iterates over the rows, and the inner one iterates over the elements, reversing them as you go along.function flip(array) { if(array.length === 0) { return []; } var done = false; var pos = 0; var result = []; while(!done) { done = true; result[pos] = 0; for(var i = 0; i >> 1; if(array[i] > 0) done = false; } pos += 1; } return result; }In Python: array1d = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] #------------------------------------------------- def flipV(arr, width): rows = len(arr)//width for i in range(rows): # [0..rows) start = i * width # index of first element in row end = start + width - 1 # index of last element in row while start < end: arr[start],arr[end] = arr[end],arr[start] start += 1 end -= 1 #------------------------------------------------- def print2D(arr, width): rows = len(arr)//width for i in range(rows): # [0..rows) rowStart = i * width # start of row(i) for j in range(width): # [0..width) print(arr[rowStart + j], " ", end='') print() print(array1d) # original print2D(array1d, 4) flipV(array1d, 4) print(array1d) # flipped print2D(array1d, 4)Show more responsesResult: >>> Input [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Output [3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12] 3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 12

Oct. 13, 2010
 How to multiply a number by 7 without using + and * operators?3 Answersuse bit shifting.n=n<<3-ndo the left.bit shift operation by 3 and then subtract the result by original number . eg: n=1 ,then n=n<<3 -n gives 7 , if n=2 ,then gives 14

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

Nov. 10, 2012
 In a collection of strings, output the string that occurs most often.4 AnswersI honestly had no idea how to solve this in a reasonable amount of time.HashMap map = new HashMap(); for(String str : strings) { Integer count = map.get(str) map.put(str, count != null ? count + 1: new Integer(1) ); } // then iterate through map to find the largest integer, the key will be the string with the most occurancesIts a similar answer to above, but I think using just a hash table is not correct if there is collision. Perfect hashing can be used for no collision, or an array in the hashmap.Show more responses@baldeagle you don't need to iterate through the list again to get the max. Just keep track of the curMax as you're inserting into the list.

### Software Developer at Mobials was asked...

Apr. 15, 2019
 Are you serious? Companies still use [insert outdated technology here]???2 AnswersYes, this is what I do.Thank you for your feedback and we apologize that you felt you had a negative experience during your interview. The candidate experience is very important to us. At Mobials we appreciate and value all past experiences that a candidates brings to a position including any previously used technology. We have shared this feedback with our hiring mangers, reminding them of our dedication to a providing a positive and professional interview experience for our candidates.

### Coop-Software Developer at BlackBerry was asked...

Mar. 19, 2009
 If given an infinite amount of memory, whats the fastest way to reverse an array?3 AnswersSplit the array in half, reverse them, split the two in half, reverse them, etc. until you cannot reverse anymore.Allocate an array of equal size and write the last index of original array to 0th index of 1st array .. (n-1)th to 1st index and so onUse a temp variable and do swap for half of the array

### Software Developer at Varicent Software was asked...

May 11, 2012
 You are given an array of integer numbers (not sorted, possibly negative, with possible repetitions). You are required to write a function that, given a number x, would find whether there are two numbers in the array summing up to this x. 3 AnswersSort the array. Then, work with two indexes. The indexes are initialized to point to the first and the last element of the array. Write a for loop, each iteration of which would do the following: check whether the sum of the two numbers currently pointed to by indexes is greater or smaller than the target sum. If equal => found. If greater/smaller => one of the indexes can be advanced. E.g., if smaller than the number pointed by the lower index will never be one of the numbers summing up to the target sum.If you use two loops, the cost of your algorithm will be N^2. There is an algorithm for this problem which costs N log(N). Sort the array A by merge sort (or any quick sort like Quick sort): Cost N log(N) In a loop, for each item of A, like A[i] use binary search and check if you can find -A[i]. (each search costs log(N) and the total cost will be N log(N))1.Sort the array using merge sort 2.loop in array arr with I=first and j=last index Check =arr[i]+arr[j] If check =x break If checkx j-- Display the value at I n j index of array

Apr. 26, 2013