Interview questions

Team Lead/ Tech Lead interview questions – page 8

3,203 questions. Tap “Show answer” to check yourself.

  1. Given a stack and any other data structure, write the code for push() , pop(), max_stack() in O(1) complexity.

  2. Write code to add 2 hexadecimal nos, whose digits are represented as nodes of Linked List, one digit per node... and one linked list per hexadecimal number. eg. Head->2->A->9->NULL for 2A9 Like this u take 2 hexadecimal nos...

  3. You have given a binary search tree. Using this tree make a sorted doubly linked list using the elements of binary tree. ( this should be done in place. That means once you are done with procedure your tree should destroy and it should be converte...

  4. Program to tokenize a given string

  5. Given an array of Integers, if u are on ith element u can make max arr jumps. If i am at an element with value zero, i cannot move forward. find the least selection to reach end of the array. ex: 1 3 5 8 9 2 6 7 6 8 9 starting with arr...

  6. You are given an array of size N; filled with numbers from 1 to N (in random order). One no. is missing and one no. is repeated twice. Find missing no. and repeated no. in time complexity O(n) and space complexity O(1).

  7. Given stwo strings, find the characters which are in first string and not in the second one and vice-versa

  8. Write the pseudocode and C++/Java code to mirror a binary tree.

  9. BST vs Hash Tables, how to decide to choose one of them?

  10. Middle of a linked list

  11. What is an AVL tree? How is it created?

  12. Given a binary tree, find out if the tree can be folded or not.

  13. Write a method to find the smallest angle between two hands when the time is given as input?

  14. Write a function to check if the two passed strings are anagrams of each other.

  15. I have a linked list contains all of the alphabets from A to Z. I want to find the letter Q in the list, how does you perform the search to find the

  16. Given a sorted array which is rotated circularly x times. find x very optimally

  17. Product date salesp1 20/Jan/1999 100p1 20/Feb/1999 200p1 20/apl/1999 100p1 20/DEC/1999 50p1 20/Jan/2000 100p1 20/mar/2000 500now i want query like product ,sum of actual year ,sum of business yearp1 450 750here actual year means 1 Jan 1999 to 31 st Jan 19

  18. Find the nearest sibling of a given node in a tree. Nodes on same level are siblings of each other.

  19. Let S={i*i:1<=i<=100}be a array of integers. A subarray T of S is called a intersting subarray if |T|=30(i.e.cardinality of T is 30)and there exist no other distinct subarray of S of cardinality 30 whose sum equal to sum(T).Write a pro...

  20. In a linked-list the nodes are 1 2 3 4 5 67 8 9 we have to rearrange linked-list so that it contain nodes are 3 2 1 6 5 4 9 8 7

  21. Write insert function for a binary search tree? Given constraint: 1. The insertion should be such that the tree remains balanced. 2. You can move any non-leaf/root node to be a leaf/non-root node.

  22. Find the longest palindrome in a given string ?

  23. Given a (Directed/Non Directed) graph and a source node and destination node . Find all the paths from a source node to the destination node. Both for directed and non-directed graph.

  24. You are given the address to the head of a single liked list and a random number generator (generates between 0-1). You have to return a node form the list randomly using the random number generator. The constraint is ...we have to tra...

  25. How will you implement tree in real life example.

  26. Min and max nodes of a quad tree

  27. You are given a tree with the root and three nodes X, Y and Z. Write a function that returns true if Y lies in a path from X to Z, otherwise returns false.

  28. Construct tree from the given ancestor matrix, optimize your solution.

  29. In a Binary Tree, you have two pointers in the parent for left and right child. You have to change the given binary tree such that you have pointer for first child and next sibling from a node.

  30. Given a binary tree, find the sum of all horizontal levels of the tree, storing the values in a suitable data structure.

Companies that ask Team Lead/ Tech Lead questions