Saturday, February 27, 2016

Interview Preparation Questions

1. Find the shortest substring that has atleast M distinct characters. Example: M = 3; Original string: AABBAAC Answer: BAAC

2. Length of the longest substring without repeating characters.

3.  Given a binary tree, check if it is a binary search tree or not.

4. Given n coins for two players playing a game. Each player can pick at least 1 and at most 5 coins in one turn. The player who picks the last coin loses the game. If they play optimally, which player will win the game?


5.  Given a continues stream of number, find the one with maximum occurrence. the same can be used for words as well


6. Least common ancestor in a binary tree - not BST binary tree


7. The handshake problems: one where outside person asks the question and one where the host does.

8. Given a running stream of numbers, find the median for them.

9. Given a string of 0 to n numbers find the missing number.

10. Given 1000 bottles with poison in them, find the minimum number of cats required to find the poison bottle.

11. Given 10 coins with equal number of head and tails, divide them into two groups such that both have the same number of heads and tails 

12. Given  two words find : union , intersection and difference in them

13. Given a list of words, find the prefix for each wrds to uniquely identify them.

14. Reverse a linked list.

15. Find set of continuous elements in array which sum to target.

16. Convert binary tree to double linked list.

17. Find height of tree.

18. Print paths to all leaves in a tree.

19. Get shorted path from one node to another in a graph.

20. Find k nearest element to origin.

21. Find all possible permutations of a string 

22. Convert a number into its word representation.

23. Convert roman numerals string to integer.

24. Validate whether tree is binary or not.

25. Check if string is palindrome

26. Find duplicates in list.

27. Check if string is anagram.

28. Travel n ary tree breadth wise.

29. Find if number is prime or not.

30. N-Queen Problem

31. Stable marriage problem.

32. Given a set of distinct integers, S, return all possible subsets.
      If S = [1,2,3], a solution is:
      [
  [],
  [1],
  [1, 2],
  [1, 2, 3],
  [1, 3],
  [2],
  [2, 3],
  [3],
]
33.  Print Left View of a binary tree.

No comments:

Post a Comment

Comment!!

Victoria Canada Trip

 Victoria city to do and must have  1. Parliament building  2. Waterfront  3. Mini sea-bus at waterfront  4. Fisherman wharf   5. Museum (op...