# Algorithm Interview Questions

interview questions shared by candidates

## Algorithm Interview Questions

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. |

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. |

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? |

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

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? |

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. |

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. |

How would you implement integer division if your language did not offer it. |

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? |

Output a single linked list in reverse, in linear time and constant space, and recursively |

**31**–

**40**of

**785**Interview Questions