Interview questions

Algorithm interview questions – page 27

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

  1. Code to flip the image horizontally.

  2. Explain any algorithm with flowchart?

  3. Pagging and Segmantation

  4. You have two lists, each containing position of a word in some document. Write a program that returns minimum distance between the words in the document. For example: Suppose X occurs at places {2, 3, 5, 10, 12, 16, 19, 20} and Y occurs at ...

  5. There are few numbers considered to be unlucky(It contains only 4 and 7. ). Our goal is to find count of such nnumbers in the range of positive integers a and b. For Example: Input:: a = 10 b = 20 Output:: 0

  6. What is the best approach to implement Fibonacci series?(recursions or without recursion).In case of no recursion could you optimize your approach further?(Consider Branch pruning).

  7. There is a sorted array. Some numbers from the start have been rotated left. [ just like left rotate with carry ]. Now give the algo of bin search to find an element in O(lg n) time

  8. What is tiny URL? How would you implement?

  9. One number is missing from an unordered array of 1-100. How will you find the missing number effectively?

  10. Given a circular road and a set of petrol pumps located at distances d1 d2 ... dn away from each other and supplying p1 p2 p3 ... pn amounts of fuel and your vehicle has a mileage of 1km/l. Determine the feasibility of going around the path starti...

  11. Given an array and an integer k , find the maximum for each and every contiguous sub array of size k .

  12. Given an integer array, sort the integer array such that the concatenated integer of the result array is max. e.g. [4, 94, 9, 14, 1] will be sorted to [9,94,4,14,1] where the result integer is 9944141.

  13. Given an array of random numbers. Find the longest consecutive sequence. For ex Array 100 3 200 1 2 4 Ans 1 2 3 4 Array 101 2 3 104 5 103 9 102 Ans 101 102 103 104

  14. Given a m*n matrix, find the subset rectangle with max sum (any other rectangle taken would have lesser sum) Best Regards

  15. What is the time complexity of Binary Search?

  16. How to count inversions in a sorted array?

  17. Given a binary tree, implement an iterator that will iterate through its elements?

  18. How will you design a Google Search?

  19. What are the advantages and disadvantages of circular queue in linked lists?

  20. Given a big string of characters, how to efficiently find the first unique character in it?

  21. How many degrees (if any) are there in the angle between the hour and minute hands of a clock when the time is a quarter past three?

  22. Identify the next number in the sequence - 31, 28, 31, 30, __?

  23. What exactly ad-hoc testing is?

  24. Given two files that has list of words (one per line), write a program to show the intersection.

  25. How do you determine if every digit in the binary representation of a number is a one?

  26. How to swap nibbles in a given character?

  27. What are dangling and smart pointers? How do you avoid Memory Leaks?

  28. Given an array of integers. Modify the array by moving all the zeros to the end (right side). The order of the other elements doesn't matter?

  29. Given an array A with n integers. Rearrange array such that A[0]<=A[1]>=A[2]<=A[3]>=A[4]<=A[5] and so on. You have to do it in linear time O(N)

  30. Why Should I hire you,As I know you have recently joined One Of The Company from One Month?

Companies that ask Algorithm questions