Algorithm Interview Questions | Glassdoor

Algorithm Interview Questions

4,795

interview questions shared by candidates

Algorithm Interview Questions

Sort: RelevancePopular Date

Find the second largest element in a Binary Search Tree

16 Answers

find the right most element. If this is a right node with no children, return its parent. if this is not, return the largest element of its left child.

One addition is the situation where the tree has no right branch (root is largest). In this special case, it does not have a parent. So it's better to keep track of parent and current pointers, if different, the original method by the candidate works well, if the same (which means the root situation), find the largest of its left branch.

if (root == null || (!root.hasRightChild() ) { return null;} else return findSecondGreatest(root, root.getValue()); value findSecondGreatest(Node curr, value oldValue) { if(curr.hasRightChild()) { return (findSecondGreatest( curr.getRightChild(), curr.value)); } else return oldValue; }

One or more comments have been removed.
Please see our Community Guidelines or Terms of Service for more information.

Describe and code an algorithm that returns the first duplicate character in a string?

12 Answers

Write some pseudo code to raise a number to a power.

11 Answers

Suppose you have a matrix of numbers. How can you easily compute the sum of any rectangle (i.e. a range [row_start, row_end, col_start, col_end]) of those numbers? How would you code this?

8 Answers

How many unique handshakes if each person in a group of 10 give handshakes out to each and every other individual. (a) 100 (b) 50 (c) 45 (d) 20 (e) 10

5 Answers

Write code in your favorite programming language that will accept two strings and return true if they are anagrams.

2 Answers

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

63 Answers

given 20 "destructable" light bulbs(which breaks at certain height), and a building with 100 floors, how do you determine the height that the light bulb breaks.

56 Answers

25 horses, 5 race tracks. How many races you have to run to select top 5 horses.

60 Answers

Allergy,posting date according to timezone,person demographics problem Medication Frequency problem and given error log to identify error Fever temperature problem and discuss a time when you automated a task to make life easier

43 Answers
110 of 4,795 Interview Questions