Interview questions
Algorithm interview questions – page 2
811 questions. Tap “Show answer” to check yourself.
-
Given a set of N points where each point is represented as a combination of x and y coordinates, print all sets of collinear points such that set size is more than or equal to 3.
-
A central server needs to pull, push data from 3,4 totally different applications [on remote machines]. Design the system such that 3a) The server has the minimum knowledge about the applications, application interface etc. 3b) The app...
-
Given a NxN matrix with 0s and 1s. now whenever you encounter a 0 make the corresponding row and column elements 0.
-
To write a function which given two dates, checks whether the dates are exactly 1 month apart(e.g June 06 2011 & July 06 2011, Dec 15 2010 & Jan 15 2011 ), less than 1 month apart(e.g Mar 01 2011 & Mar 25 2011, Jun 20 2011 & July 1...
-
Given a set of N lines of English language, each comprises only of a-z and A-Z. For each line, find the alphabets which have highest frequency of occurance and print them (with capital letters first then small letters in increasing order in their ...
-
Lets say you have to construct google maps from scratch and guide a person standing on Gateway of India (Mumbai) to India Gate(Delhi).How do you do the same ?
-
If a person dials a sequence of numbers on the telephone, what possible words/strings can be formed from the letters associated with those numbers?
-
Design an algorithm to play a game of Frogger and then code the solution. The object of the game is to direct a frog to avoid cars while crossing a busy road. You may represent a road lane via an array. Generalize the solution for an N-lane road. ...
-
How to arrange round robin matches among the N teams so that same team can't play more than one match in same day. What will be total numbers of day for the matches.
-
Given a number x, find the smallest prime number which is greater than x.
-
You are provided with m arrays of n length each. The arrays are initially sorted. Give the algo to get one sorted array of mn length out of these. The interviewer told me to this in minimum space and time complexity.
-
You have n1 items of size s1, n2 items of size s2, and n3 items of size s3. You'd like to pack all of these items into bins each of capacity C, such that the total number of bins used is minimized.
-
There was a party.there was a log register in which entry and exit time of all the guests was logged.you have to tell the time at which there was maximum guest in the party. input will be the entry and exit time of all the n guests [1,4] [2,...
-
Design a jigsaw puzzle?
-
There are N numbers from 1 to N and there a is game to be played that starting from 1 every second num wud be eliminated ... perform this until there wud be only single num remained ... give an efficient algo to calculate which num will rem...
-
Given a file and and API containing getline() to read lines from it, how will u print only the unique lines from it.
-
You have 6 coins of Indian denomination (a+b+c+d+e+f=115 paisa) ...if user ask for a change of 100,50,25,10,5 paisa then you r not able to give find the value of a,b,c,d,e,f...e.g. lets if user ask for a change of 25 paisa then you r n...
-
There is a row of houses in which each house contains some amount of money. Write an algorithm that loots the maximum amount of money from these houses. The only restriction is that you cannot loot two houses that are directly next to each other...
-
We are given N blocks of height 1N. In how many ways can we arrange these blocks in a row such that when viewed from left we can see only L blocks (rest are hidden by taller blocks) and when seen from right we see only R blocks? for N=3, L=2, R...
-
Proove The Time Complexity of Sieve of Eratosthenes is O(nlog(logn))..Interview wants from clean Mathematical Proof..for this..
-
Given a graph's shortest path algorithm, how can you make use of it to find the second shortest path?
-
Write an Algorithm to Implement the Syntax highlighter what will be the complexity of algo. Which data Structure You Will Use fro that then Write a Program to Implement the Syntax highlighter
-
There is a drought situation in Agrabah. King got worried and called Aladdin for helping him out. As he is a modern Aladdin he took printouts of places around Agrabah from google maps.For analyzing the map properly, he converted the map into a M x...
-
Given 2 trees A and B find if tree B is a subtree of Tree A or not. Provide the most optimized solution that you can think of.
-
We have three arrays A=[a1,a2,...an] B=[b1,b2,...bn] C=[c1,c2,...cn]
-
As we know that each user has only 4 digit acc. no. We have billions of user what is maximum bounds on these no. What algo used to generate 4 digit unique no. & what are the possible 4 digit nos. we can have...
-
. Given N arrays containing values between 0 to x, what data structure would you use to store these arrays so that when given a test array t find the closest array in N that has highest number of elements in t? Also what algorithm woul...
-
Discuss time and space complexities of merge sort. When is it preferred over quick sort?
-
You are given a stream of numbers which can be positive or negative. You are required to provide an operation FIND MEDIAN..which when invoked should be able return the median of the numbers in stream (in sorted order) in O(1) tim...
-
Consider a right angled Triangle ABC, right angled at B. Length of side A (side opposite to angle A)is given. Write a function to find the lengths of side B and side C. The function should take the inputs ( Length of side A and one acute angle eit...