Recent Interview Questions
0of 0 votesYou are given a long list of integers, so long that you can not fit the entire list into memory, implement an algorithm to get the max 100 elements in the list.
0of 0 votesGiven these 4 commands :increment, zero, assign, loop. Define these 4 function: Decrement, Divide, test If equal (pseudo code).
0of 0 votesYou have an array of binary numbers as "00001101000001010100000..."... We need to find the First occurrence of 1 in this series.. using binary search.
we need to design an algorithm of complexity less than O(n).. and we need to use binary search strictly..
0of 0 votesUsing these 3 functions:
INCREMENT: READ N1 WRITE N1 + 1 MINUS: READ N1, N2 WRITE N1 - N2 MULTIPLY: READ N1,N2 WRITE N1*N2Define these four functions: Greater than, Equality, Nonequality, Divide.
0of 0 votesHow can you implement multiplication operator using increment operator (No arithmetic operation is allowed)?
0of 0 votesWrite a function to evaluate a string that has only integers, and operators '+' & '*'. The evaluation should be done in a single pass. For example passing "3*2+5*6" should result in this function returning 36.
0of 0 votesWrite a function fix a loop in the linked list based on the assumption that the linked list is sorted.
0of 0 votesHow would you find if a linked list has a loop? How would you do it without using additional memory, if the linked list is sorted.
0of 0 votesWrite a function to find a key in Hash map if the value associated to that key is given as input. As a followup, swap key & value assuming that value is not equal to any of the existing keys.
0of 0 votesWrite a function to perform string replace without using any inbuilt functions.
0of 0 votes// Given two lists of strings build a new list that has all strings that appear in both the original lists. If the same string appears more than once output it as many times as it appears in both lists
//
// Example:
// "dog", "bird", "elephant", "dog", "dog", "cat"
// "cat", "dog", "dog", "cat", "cat", "fish"
// Result (order doesn't matter)
// "dog", "dog", "cat"
0of 0 votes//Given an array of NxN, print its diagonals from top-right to bottom-left.
//Sample Input:
// [[1, 2, 3],
// [4, 5, 6],
// [7, 8, 9]]
//Sample Output:
//1,
//2, 4,
//3, 5, 7,
//6, 8,
//9
0of 0 votesGiven an array of values, design and code an algorithm that returns whether there are two duplicates within k indices of each other? k indices and within plus or minus l (value) of each other? Do all, even the latter, in O(n) running time and O(k) space.
0of 0 votesGive three Hash tables has some values.you need compare three hash tables and store the common values in fourth hash table?
2of 2 votesEliminate all ‘b’ and ‘ac’ in an array of characters, you have to replace them in-place, and you are only allowed to iterate over the char array once.
Examples:
abc -> ac
ac->''
react->rt
0of 0 votesThe bin packing problem is an example of a wide set of problems. The task is to find how many set sized bins are required to hold a number of differently sized boxes. How many bins (10 units high) are required to contain the following boxes (1,3,4 and 5 units high)?
0of 0 votesWrite a program to calculate the Loan Balance, where a person borrows an amount A and in return he/she agrees to make N payments per year, each of amount P. While the person is repaying the loan, interest will accumulate at an annual percentage rate of R, and this interest will be compounded N times a year (along with each payment). Therefore, the person must continue paying these installments of amount P until the original amount and any accumulated interest is repaid.
NOTE: The formula to calculate the amount that the person needs to repay after T years is -
Balance Amount after T years = A[(1+R/N)^NT]-P
0of 0 votesCode to check if a given short string is a substring of a main string. Can you get a linear solution (O(n)) if possible?
0of 0 votesGiven a circular linked list, find the mid element of the linked list.
0of 0 votesExplain how you would implement a multi-map in Java without using any collections?
0of 0 votesTwo numbers are represented as linked lists. Both lists are of same length. Add them without manipulating the lists and without a second traversal.
-1of 1 voteWhat is system.gc() and runtime.gc() ?
1of 1 voteWhich will take less time to retrieve the data if numbers are present in hashmap and sorted array .
0of 0 votesAn array of zero and non zero integer are their having range 10000 (i.e length of array is 10,000)
Arrange the array in such a way that zero comes first and after that the non zero integer.
1of 1 voteFind duplicates in infinite range .
Which data structure to be used to give efficient solution.?
I answered HashMap .
How to implement using boolean array.?
0of 0 votesYou are given an application which sometimes may go into infinite loop.
Come up with a deployment plan s.t. the erring process is killed as soon as it goes into infinite loop.
0of 0 votesPlease consider the following tables:
Code:
Table Name: Person
Person_Id Name
Table Name: DVD
DVD_ID Owner_ID Title
Here is the query:
Write a query that returns the list of DVDs that belong to owners who own “Superman”
Here is my solution:
Code:
SELECT p.name,d.dvd_id
FROM DVD d,Person p
WHERE p.person_id = d.dvd_id
AND Title = 'Superman' ;
I answered above answer. But interviewer was expecting me to do using Subquery. Is that possible?Please let me know if the above query is correct or not.
0of 0 votesDesign a chess game. Write all classes and methods.
1of 1 voteGiven a large file of (x,y) coordinates. Find the k farthest points from origin.
1of 1 voteGiven a network of printers and systems. Allocate the nearest printer to each system. How will you handle dynamic addition of printers and systems.
