Interview questions

Team Lead/ Tech Lead interview questions – page 5

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

  1. Write a function to find the nearest link on a webpage given the mouse x, y coordinates.

  2. Give an algorithm to find the minimum-depth of a binary tree. A node is complete if it has both left & right child. Looking for a non-recursive approach.

  3. You are provided with a stream of numbers, design a data structure to store the numbers in the stream along with their no. of occurrences

  4. Read a file of this format:

  5. Write a code segment called isFibonacci(), which, when given a variable array of integers, checks whether it is a part of the Fibonacci sequence or not? (This was asked for the second round)

  6. Suppse a binary tree is stored in an array( a) such that a[i] is the parent of i. Suppose one element is 5, so the parent of the element 5 is in a[5], the parent of the root is -1. It is not a binary seach tree. So what will be the "easiest" imple...

  7. Given an n*m matrix of letters and a dictionary find all the valid words from it.Implement the functions that you wud use on dictionary .Ex func like bool isValidWord(String) ..which you would use on dictionary

  8. Write a function to find out if a given tree is a binary search tree (BST) or not? Remember to use minimal space. For eg, we know that if an inorder traversal of the tree gives a sorted set of elements then it is a BST else it is not. But this re...

  9. A matrix full of L(land) and D's(Deserts). At each time D converts surrounding L's to D's. Deserts eats Land. Given a matrix find out scenario after t time

  10. If u could find the (n/4)th element of an array in O(n) time, then what is the worst time complexity of quick sort algo if this algo is used to decide the pivot element.

  11. The next highest number in the given sequence ex: input:213476-->213467 54321--> -1

  12. The store placed the paper order forms in a 10x10 array of bins, using the last two digits of the customer's phone number as the hash index. When the customer telephoned an order, it was placed in the proper bin. When the customer arri...

  13. Which algorithm is better among quick sort and Heapsort and why?

  14. There is a file with the following pattern

  15. How will you design google map?

  16. Longest Common Prefix from N strings of max length "m". I gave a naive approach of O(n.m) and O(m.logn) with some adjustments but Interviewer wanted something O(n+m) or better than O(n.m). Please suggest solutions. eg: Flow...

  17. Find the min and max in an array. Now do it in less than 2n comparisons. (they were looking for the solution that finds both max and min in about 3/2 n comparisons).

  18. Assuming you are a unix/linux community developer Write the algorithm to simulate tail -n command of linux. n = number of lines to print. [FYI Tail -n will print out the last n lines of any file.]

  19. Given two unsorted int arrays, find the kth element in the merged, sorted array. example: int[] a= [3 1 7] int[] b = [4 9] k: 3 return 4.

  20. Give an example of an algorithm with time complexity O(1/n)?

  21. Write a function that counts the number of words from a given string. Example: "I like this page so much" should give us 6 total.

  22. There is a function which returns 0 or 1. You need to pass each and every element of the array one by one to that function and depending on the return value, you need to store all the numbers in such a way that all the true values should appear fi...

  23. Write the code/algorithm to find the k-th Smallest Element in the Union of Two Sorted Arrays.

  24. You are given a set of boxes b1 to bn. Each box bj has an associated width wj , height hj and depth dj. Give an algorithm for creating the highest possible stack of boxes with the constraint that if box bj is stacked on box bi, the 2D base of bi m...

  25. A helicopter drops two trains, each on a parachute, onto a straight infinite railway line. There is an undefined distance between the two trains. Each faces the same direction, and upon landing, the parachute attached to each train falls to the gr...

  26. Design the data structure & algorithm for elevator. Step by step, walk through the logic/algorithm of elevator moving up & when elevator is going down

  27. Suggest data structure for dictionary with features like * autocorrect * autocomplete * spellcheck

  28. Given array of integers, return an index such that it divides the array in 2 parts ,i.e.sum of all elements which are left side of the index = sum of all elements which are right side of the index. Do in linear time.

  29. There is a portal with two billion users registered. If you store all the 2 billion users in a conventional databases it will take more time to retrieve the data about a particular user when that user tries to login. How do you handle this situati...

  30. Given a function RAND5 that genrates random numbers in the range 0 t0 5 write afunction that RAND7?

Companies that ask Team Lead/ Tech Lead questions