Algorithm Interview Questions | Glassdoor

Algorithm Interview Questions


interview questions shared by candidates

Algorithm Interview Questions

Sort: RelevancePopular Date

If you had 5,623 participants in a tournament, how many games would need to be played to determine the winner

61 Answers

Before I could figure that out, I'd need to know whether the # of participants represents the number of individuals on larger teams, or the number of teams

A specific numerical answer can be given, but there are multiple ways the tournament can be setup, for example, are there play-in games, byes, etc. I would think the question is being given to a manager to see how they think and process, and then come up with a specific numerical answer, as opposed to just a math problem.

It can be just one game. A huge mock battle.

Number of 1's in binary representation of integer?

13 Answers

Write a function Brackets(int n) that prints all combinations of well-formed brackets. For Brackets(3) the output would be ((())) (()()) (())() ()(()) ()()()

11 Answers

Given an array of integers where each element points to the index of the next element how would you detect if there is a cycle in this array?

18 Answers

Implement a power function to raise a double to an int power, including negative powers.

11 Answers

Given an array of integers eg [1,2,-3,1] find whether there is a sub-sequence that sums to 0 and return it (eg 1,2,-3 or 2,-3,1) Checking every sub-sequence is O(n^2) which is too inefficient

15 Answers

Implement a function to validate whether a given binary tree is a BST (i.e. write an isBST() function).

9 Answers

Given a string, remove all the duplicate characters (not necessarily consecutive)

9 Answers

(a) first, write a function to calculate the hamming distance between two binary numbers (b) write a function that takes a list of binary numbers and returns the sum of the hamming distances for each pair (c) find a solution for (b) that works in O(n) time.

10 Answers

Print a singly-linked list backwards, in constant space and linear time.

10 Answers
110 of 759 Interview Questions