# Developer Interview Questions

Developer interview questions shared by candidates

## Top Interview Questions

write a function that returns the first unique element in an array What the type of elements in the array? If character, set up the hash table, and scan the array. the hash table stores the index of each element. If the element appears more than once, update the table as a negetive value. After scanning, find the smallest index value from the hash table, which would be the first uniqure element. The time complex gonna be O(n), where n is the length of array. I wrote a sample program here. (I use map container here to replace hash_map. The doesnot work on my computer) #include "stdafx.h" #include #include using namespace std; static int find_unique_ele(char*,int); int _tmain(int argc, _TCHAR* argv[]) { char test[6] = {'a','b','c','b','c','a'}; int min_index = find_unique_ele(test,6); if (min_index store_table_value; map store_table; while(i ::const_iterator test_it = store_table.find(*test); if(test_it != store_table.end()){ store_table[*test] = -1; } else{ store_table.insert(map::value_type(store_table_value(*test,i))); } i++; test++; } map::const_iterator table_it = store_table.begin(); store_table_value temp_value = *table_it; int min_index = temp_value.second; while(++table_it != store_table.end()){ temp_value = *table_it; if(temp_value.second < min_index || min_index < 0){ min_index = temp_value.second; } } return min_index; } I think in the above solution you have to scan the original array twice making it order (2n) or O(n). The 2nd scan is needed to determine the corresponding entry in the hash table whether it is unique or not. We need this to determine the first unique element in the array. Show more responses |

The questions were not very difficult but you really need to have all the concepts crystal-clear and be ready to apply them successfully. One of the questions was "how to count the letters in this string:" "The quick brown fox jumps over the lazy dog"; |

How would you measure 4 litres of water if you have 3 litre and 5 litre canisters? |

int i=14; if (i=15) i++; How much is i? |

Given 9 ball with only one differ in weight, how to find out by measuring them only twice? |

A rabbit wants to climb some stairs and it can do steps of 1 or 2. How many possible paths are there to follow ( e.g 1-1-1... or 2-2-2 ... or 2-1-2-1... etc) |

Russian roulette brain teaser: Interviewer takes an imaginary revolver gun with 6 empty chambers, and loads 2 adjacent chambers with bullets. Interviewer has the first turn: rolls the cylinder, puts it to his head, and pulls the trigger... no shot. The lucky interviewer passes the gun to you and gives you two options before you put the gun to your head and pull the trigger: (a) to roll the cylinder again or (b) not to roll the cylinder Which option would you choose? |

2 pieces of string of different length and non-uniform width, each take one hour to burn. the remaining length of a burning string doesn't tell you how much longer it burns for. with a lighter measure 45 mins. |

What is your age |

Asked question: Using an already implemented method Rand5() that generates a random integer between the ranges 1-5 uniformly. Using this method, implement a a new method that returns a random integer in the range 1-7 uniformly, i.e. Rand7(). Basically this is Rejection Sampling Algorithm. See http://leetcode.com/2010/11/rejection-sampling.html |

**1**–

**10**of

**3,515**Interview Questions

## See Interview Questions for Similar Jobs

- Software Engineer
- Software Developer
- Senior Software Developer
- Senior Software Engineer
- Technology Analyst
- Analyst
- Graduate Software Engineer
- Intern
- Software Development Engineer
- Graduate Software Developer
- Financial Sales and Analytics
- Data Analyst
- Project Manager
- Summer Analyst
- Vice President
- Software Development Engineer II
- Software Engineer III
- Software Development Engineer I