Programming Interview Questions | Glassdoor

# Programming Interview Questions

217

interview questions shared by candidates

## Programming Interview Questions

Sort: RelevancePopular Date

### Software Engineer at PayPal was asked...

Nov 10, 2011
 What is the output from this code (assume int is 32 bit) int f(int n) { return n * f(n-1); } print(f(100));2 Answersnever returns. infinite recurrence.because no base case to stop the infinite loop

### Software Engineer at Ericsson-Worldwide was asked...

Sep 21, 2010
 given a number, how do you determine if its a power of 3?4 Answerskeep dividing by 3 and eventually you should get 3 as quotientThe addition of all ciphers in number must be dividable by 3, similar as 9. Test by dividing by 3 is wrong, because division is slow operation and also the complexity of it depends on a number size.It's not asking whether the number is divisible by 3. It's asking whether it is power of 3.Show More ResponsesTake the cube root of the number, if the result is a whole number, it is a "power of 3".

### Mobile Developer at Pocket Gems was asked...

Feb 20, 2012
 Given an array of 0's and 1's, and a number k, find the minimum window that contains k 0's. Write code.1 AnswerCan be solved using DP. 1. Pick the index of first appearance of 0.-> Findex 2. increment pointer updating Parent index with the index position where the previous 0 was found till k 0's are found. -> Lindex 3. maintain index range and the window size. 4. after we going through all the elements, the index range with minimum window size is returned. if k = 4 e.g index 1 2 3 4 5 6 7 8 9 10 11 12 ------------------------------------------------------------------------- 0 0 1 0 1 1 0 1 0 0 1 0 Parent 1 1 x 2 x x 4 x 7 9 x 10 range x x x x x x (1,7) x (1,7) (1,7) x (7,12) minrange x x x x x x 7 7 7 7 7 6 The final answer is (7,12)

### Mobile Developer at Pocket Gems was asked...

Feb 20, 2012
 How would you check if a binary tree is balanced? Write a program to implement your algorithm.1 AnswerTree, Binary, Balanced, Programming

Nov 2, 2011

### Associate Technology L2 at Sapient was asked...

Jul 23, 2011
 Case study-create an application for a service scheduling company. Can use pseudocode, programming language, etc.1 AnswerUsed the whiteboards to create a presentation using Java and pseudocode. Afterwards present to 3 people as if they were clients.

### Software Engineer/Developer for Microsoft Windows Azure Fabirc Foundations Group at Microsoft was asked...

May 9, 2011
 Write a procedure in C that reverses the letters of a null-terminated string. Then write another procedure in C that reverses the words of a null-terminated sentence.1 AnswerThere are answers that are space optimal (e.g., reverse the words of a sentence by reversing the letters of a sentence and then reversing the letters of each word in place) and other answers that are time optimal (e.g., copy data into new data structures with the desired properties). This apparently is also another classic programming interview question.

### Marketplace Web Service Engineer at Amazon was asked...

Sep 10, 2010
 Write a function that takes in a list of numbers and returns the number of even numbers in the list.2 AnswersIn Clojure one solution would be: (def numlist (range 100)) (filter #(= (mod % 2) 0) numlist)In ruby one can do ``` def even_numbers(arr) arr.select { |n| n % 2 == 0 } end ````

### Senior Engineer at Wind River was asked...

Feb 7, 2012
 Questions on Semaphore, Mutex and C programming based on a scenario.1 AnswerThe answer required understanding of Wind River's flagship product specifically and concepts of Real Time Operating System.

### Senior Software Engineer at EMC was asked...

Oct 1, 2010
 Find the logical error in the Linkedlist reversal program (the program was given). Need to use the gdb tool to debug and correct the program.1 AnswerThe linked list should be reversed in one pass. This uses stack datastructure. As you traverse the linked list from head node to tail node, take the node and put it in the front of the new linked list (i.e. reversed output linked list). They basically check if you can use debugger tools to find/correct the error in the program.
5160 of 217 Interview Questions