Algorithm Interview Questions | Glassdoor

Algorithm Interview Questions

766

interview questions shared by candidates

Algorithm Interview Questions

Sort: RelevancePopular Date

Considering a 2-dimension matrix that can only be traversed by 1 adjacent position at a time and never diagonally. Create an algorithm to traverse that matrix from its upper-left corner to its lower-right corner using the shorter possible path in the most efficient way.

6 Answers

Write a function in Java that will take a sorted array of ints, possibly with duplicates, and compact the array removing all the duplicate numbers. That is, if the contains the numbers - 1, 3, 7, 7, 8, 9, 9, 9, 10, then when the function returns, the contents should be - 1, 3, 7, 8, 9, 10. Be sure your answer is as efficient as possible. Describe the efficiency of your algorithm using big O notation.

5 Answers

Write an algorithm to verify if a tree is a binary search tree.

5 Answers

Suppose you have 100 GB of data that you want to sort, but you only have 1 GB of memory. How would you sort this data?

8 Answers

Write a program that given 4 coin denominations and a dollar amount finds the best way to express that amount using the coins given. I.e. you have coins with denominations of 1c, 7c, 13c,19c and you have to express $2.12 with the least number of coins. There is always a 1c coin but the other 3 are arbitrary.

6 Answers

Consider an X x Y array of 1's and 0s. The X axis represents "influences" meaning that X influences Y. So, for example, if $array[3,7] is 1 that means that 3 influences 7. An "influencer" is someone who influences every other person, but is not influenced by any other member. Given such an array, write a function to determine whether or not an "influencer" exists in the array.

12 Answers

Given a set of people, one of them is a celebrity. You have a 2D array which describes which people know each other, that is [N, M] is true if N knows M. The celebrity will not know anyone (except them self) and everyone will know the celebrity. Find an order N algorithm to find the celebrity.

7 Answers

Given a set of non-overlapping integer ranges (1,3) (5,8), etc., and an input integer, what is the best way to organize the data and allow for quick search based on the input, etc.

5 Answers

You have an analog clock with two hands, one for the hour and one for the minute. Given a time of the day, what is the angle between the two hands?

5 Answers

How many unique paths are there from B-L point to the T-R point of a chess table? What would be your approach to calculate this?

6 Answers
3140 of 766 Interview Questions