Interview questions

Algorithm interview questions – page 22

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

  1. U have an array of nos write an algo that will place multiplication of other nos at each position (I told them first multiply all elements. Let multiplication be M. Then for each element divide that element by M) He told me to do the s...

  2. Iterative and Recursive algorithm for palindrom. Which one will be memory efficient and why.

  3. 4. Specification of variables in one language: letter follow by letter or digit. options: 1. (LUD)* 2. L.(LUD)* => this one right. 3. L.(L.D)+ 4. L.(L.D)*

  4. You have a file containing lines of text and then each line has words.

  5. Columns are represented using alphabets (Like MS Excel). Example: first column - 'A' second column: 'B' . . . 26th column : 'Z' 27th: 'AA' . .

  6. Clone a connected undirected graph. Input is a node*. Return the node* of the cloned graph.

  7. Given a 4GB file of numbers. You are asked to find the product of K largest numbers. The size of the main memory is 1 GB. Give an efficient method to find.

  8. Given a very large file (millions of record), find the 10 largest numbers from it.

  9. Given an array and a number K. You have to find out longest subset from the array whose all pair sum will be greater than k. ex: {8,3,4,1,6,2,5,7,9} and K = 12 ans: {8,6,7,9} or {5,7,8,9}

  10. You are given a two dimensional character array of size n x n. It is filled with some characters. Now I will give you a name say "Ram"..and you have to find whether there exist any curve in the grid which when joined gives "Ram"

  11. In a stream of numebers, how will you find out n smallest numbers at any moment? how will u store them

  12. Write a function void DrawRectangle(char *Screen, int x1, int y1, int x2, int y2). Height and width of the monitor is known. To set a pixel, you need to set that particular bit of the screen.

  13. You are given a lot of cuboid boxes with different length, breadth and height. You need to find the maximum subset which can fit into each other. For example: If Box A has LBH as 7 8 9 If Box B has LBH as 5 6 8 If Box C has...

  14. How to find out if a point lies inside a triangle or not?

  15. Write code for a recursive solution that you created, can be any problem.

  16. There is a river and there are n number of steps between two banks of the river to cross the river.

  17. Given a text file, implement a solution to find out if a pattern similar to wild cards can be detected. For example, find if a*b*cd*, or *win or *def* exists in the text.

  18. How will you raise a n x n matrix to the power k efficiently. What's the time complexity and space complexity of you algorithm? How will you optimize this?

  19. You're given a string, and you want to split it into as few strings as possible such that each string is a palindrome. (I guess a one char string is considered a palindrome, i.e. "abc" is split into "a", "b", "c".)

  20. In a game, you bet using the following strategy. Whenever you lose a bet, you double the value of the bet for the next round. Whenever you win, the bet for the next round will be one dollar.

  21. Given a word, convert it into a palindrome with minimum addition of letters to it. letters can be added anywhere in the word. for eg if yahoo is given result shud be yahoohay. give a optimize soln

  22. Explain an algorithm for sorting a set of Strings..The constraint here is that all the strings doesn't fit in memory at a time..Please do mention the complexities of ur Algorithm

  23. There is a file system on the disc. the disc has many sectors. Always the first sector has the information about all the files.

  24. Write a function that given a list of items and weights return a random item in the list taking the weights into account.

  25. Print all the paths from root to leaf nodes of binary tree depth of the tree is provided

  26. Print permutations of a given string in sorted order

  27. 3)Given a file contiaining number of words , with one word per line .Print a string together that are anagrams

  28. Given an array of n elements and a number x, find if there exist 3 elements in the array whose sum is equal to x. Do it in O(nLogn) time complexity

  29. Implement: float evaluate(char* s) for example: input: "1+2.5" output: 3.5 output: "4-5*8+4/2" output: -34

  30. Algorithm to find the two numbers whose difference is minimum among the set of numbers.

Companies that ask Algorithm questions