Algorithm Interview Questions | Glassdoor

Algorithm Interview Questions

786

interview questions shared by candidates

Algorithm Interview Questions

Sort: Relevance Popular Date

You are given an integer N and an integer M. You are supposed to write a method void findBestCoinsThatMinimizeAverage(int N, int M) that prints the best collection of N coins that minimize the average number of minimum coins needed to generate values from 1 to M. So, if M = 100, and N = 4, then if we use the set {1, 5, 10, 25} to generate each value from 1 to 100, so that for each value the number of coins are minimized, i.e. 1 = 1 (1 coin), 2 = 1 + 1 (2 coins),..., 6 = 1 + 5 (2 coins), ..., 24 = 5 + 5 + 5 + 5 + 1 + 1 + 1 + 1 (8 coins), and we take the average of these coins, we would see that the average comes out to ~5.7. But if we instead use {1, 5, 18, 25}, the average would come out to be 3.7. We are to find that set of N coins, and print them, that produce the minimum average.

8 Answers

find 3 elements in an array that sum to 0.

6 Answers

You are given an array with n positive integers where all values in the array are repeated except for one. Return the one that is not repeated.

7 Answers

Write a function that computes the intersection of two arrays. The arrays are sorted. Then, what if one array is really larger than the other array?

6 Answers

You have a genealogy: 1) Describe a data structure to represent it. 2) Given any two people within the genealogy, describe an algorithm to determine if they share a common ancestor. You just need to return true/false, not all ancestors.

6 Answers

What are the first 2 integers that, when added together, equal 10 in a "very large" array of unsigned integers?

6 Answers

Given a series of words written using a scrambled alphabet, figure out what order the letters of the alphabet are in.

7 Answers

Given a stream of integers of unknown (possibly large) length, how would you pick one at random? Now prove its random.

6 Answers

Define binary search tree. Develop a procedure to verify a binary search tree.

6 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
2130 of 786 Interview Questions