Interview questions

Algorithm interview questions – page 11

811 questions. Tap “Show answer” to check yourself.

  1. Processing times for 5 processes were given. You need to find out the minimum average waiting time the processes have to wait in order to get executed if TWO PROCESSORS are given.

  2. What is the complexity for finding all the leaders in an array? A leader is defined as an element which is greater than all the elements to its right.

  3. Given N numbers how will you partition them so that

  4. Write a code to create a Pascal Triangle like below:

  5. Design the classes for Tic Tac Toe. Implement make next move method for the computer player and make sure that the computer wouldn't lose

  6. Given a string containing 0's and 1's. One would need to find the longest sub-string such that the count of 0's is equal to the count of 1's in the largest sub string.

  7. We have been given a deck of cards and each combination has a rating eg 3 As is higher than 2 As 1K etc. Write an algorithm such that the probability of picking 3 or 5 or 7 cards from the deck results in high rating

  8. You are given 'n' appointments. Each appointment contains startime and endtime. You have to return all conflicting appointments efficiently

  9. Write an algorithm to divide two extremely large numbers, which cannot be stored in an int, long int, float, double etc. Find the remainder and quotient

  10. You have given 2 array. You need to find whether they will create the same BST or not. For example: Array1:10 5 20 15 30 Array2:10 20 15 30 5 Result: True Array1:10 5 20 15 30 Array2:10 15 20 30 5 Result: ...

  11. Given a number is in the form of array, 34899 is given as [3, 4, 8, 9, 9] add 1 to this number and return.

  12. Couple elimination problem.

  13. Input a character array from the user and output in the following way. example string is amazon.. then output should be a2m1z1o1n1

  14. Given a large list of 2D Points (x,y) find the k closest points to a target P(x,y). - Implement the solution - Explain the running time - Explain how you can optimize your code - Explain some decisions behind why you chose ...

  15. Given a node in a graph that is reachable, how do you find all the nodes that are reachable ? How would you enable parallel computation of this information ? Given a number of cores, how many threads would you choose ?

  16. Given a set of numbers [1-N] . Find the number of subsets such that the sum of numbers in the subset is a prime number.

  17. Implement sort for a very large file. [Write a complete working code]. The interviewer shared a doc on collabedit.com and was able to see what I coded in real-time.

  18. You have a high speed network where packets are arriving on a system. Packets can be of variable length. Each incoming packet is associated with an id. Algorithm must check for the size and should do the following:

  19. Given an integer 'k' and an sorted array A (can consist of both +ve/-ve nos), output 2 integers from A such that a-b=k. PS: nlogn solution would be to check for the occurence of k-a[i] (using binary search) when you encounter a[i]. methods l...

  20. Given an unsorted array of integers, find all triplets that satisfy x^2 + y^2 = z^2.

  21. Given set of numbers, find all possible pair {(a, b) where a, b belongs to given set) of numbers whose sum is equal to s. Expecting to do this in O(n).

  22. Given an array of 50 integers a[50], if one of them a[i] is corrupted and converts to '0' then can you find the original value of the integer ?

  23. Algo to print out all the files under a given directory.

  24. Write a program to find the index in an circular array such that the string that is formed starting from that index is first in lexicographic order.

  25. Consider two non-empty zero-indexed arrays A and B consisting of N integers each. Four functions are defined based on these arrays:

  26. Print the nodes at each level of an n-ary tree, such that each level is present in a different line. Eg: 1 / 2 3 //\ /| 4 5 6 7 8 9

  27. In a matrix of characters, find an string. String can be in any way (all 8 neighbors to be considered), like find Microsoft in below matrix.

  28. You are given 2 arrays sorted in decreasing order of size m and n respectively.

  29. Describe the what is Crawler & why it is needed is dare any alternative of this exist.Explain its basic functionality using algorithm,Now Which Data-structure you will use to design web crawler for Google Mass Scalable Architecture..when shoul...

  30. A file is given with many 0s stored in continuous way , store it in another file such that when you store try saving the space by using minimum amount of space. When you want to create the original file, you should be able to do so with the ...

Companies that ask Algorithm questions