## Recent Interview Questions

- 0of 0 votes
Your job is to build a data structure to maintain a set of photographs. Your photograph database should allow you to insert and search for photographs, as well as to designate some of the photographs as favourites by marking them. In more detail, your data structure should support the following operations:

Insert(x, t, m): inserts photograph x that was taken at time t. If m = 1, then the photograph is marked as a favourite; if m = 0, then it is not a favourite.

Search(t): find the next photograph taken after time t.

NextFavorite(t): find the next photograph taken after time t that is a favourite.

Give a data structure for solving this problem, and explain how it works. For more efficiency, your data structure should be both time and space efficient: more points will be given for more efficient solutions. (Remember that the photographs themselves may be quite large.) Give the performance (i.e., running time) of each operation and the space usage of the data structure. You may assume that at any given time t, your camera has taken at most one photograph x. Describe your solution in words, or very high-level pseudocode. You do not need to provide complete details. You must provide enough detail, however, that your solution is clear.

- 0of 0 votes
Suppose you are given a puzzle that is represented as a matrix with 0s and 1s, where a 0 indicates you’re allowed to move into that position and 1 means you’re not allowed to move in that position. Write a function that given a start position and an end position, returns a boolean value indicating if there exists a path from start to end. you are only allowed to move up, left, right and down. Diagonal movement is not allowed.

Example #1

Input

0 0 1 0 1

0 0 0 0 0

0 1 1 1 1

0 1 1 0 0

start: 4,1

end 0,3

Output - true

Example #2

Input

0 0 1 1 1

0 1 0 0 0

1 1 1 1 1

0 0 0 0 1

start: 0,0

end: 1,2

Output - false

- 0of 0 votes
Implement a function that returns the i-th most popular item sold

at xyz company. You cannot rely on any libraries.

Class Item {

String itemId;

int quantitySold;

}

/**

find the i-th most popular item in the list

**/

String find(List<Item> items, int i) {

// your code goes here

}

- 0of 0 votes
Suppose you are given a puzzle that is represented as a matrix with 0s and 1s, where a 0 indicates you’re allowed to move into that position and 1 means you’re not allowed to move in that position. Write a function that given a start position and an end position, returns a boolean value indicating if there exists a path from start to end. you are only allowed to move up, left, right and down. Diagonal movement is not allowed.

Example #1

Input

0 0 1 0 1

0 0 0 0 0

0 1 1 1 1

0 1 1 0 0

start: 4,1

end 0,3

Output - true

Example #2

Input

0 0 1 1 1

0 1 0 0 0

1 1 1 1 1

0 0 0 0 1

start: 0,0

end: 1,2

Output - false

- 0of 0 votes
Design and code the sudoku solver.

- 0of 0 votes
There is a zoo and there are several groups(number of groups:K) of people for tour. Each group is having different size (g1,g2,g3…gK). There is one bus with capacity C. Journey starts from a point and bus will come back to the same point. A group can only be included in the bus if all the members of the groups can be accumulated in bus. After coming back from the tour, each group in the bus will again wait in the queue at the bus-stand. Bus-driver earns a rupee for each person travelled. You have to find the earning of the bus driver after R rounds.

For example :

Number of groups G = 4

Group size for each group : 2 4 3 5

Bus capacity : 7

Number of rounds R : 4

queue : (from front side) 2 4 3 5

First round : 2 4 (we can’t take 3rd group as 3 members can’t be accumulated after 2 and 4.)

queue : 3 5 2 4 (1st and 2nd group are enqueued. i.e. 2 and 4)

Second round : 3

queue : 5 2 4 3

Third Round : 5 2

queue : 4 3 5 2

Fourth Round : 4 3

After 4 rounds, total earning is 6+3+7+7 = 23.

- 0of 0 votes
Design a Traffic signal . List all entities and classes involved. How will you handle pedestrian crossings etc.

- 0of 0 votes
esign a contact list for a cell phone which can add & search really quick and is scalable.

- 0of 0 votes
Design a mobile cab booking application (just screens and functionalities) on board.

- 0of 0 votes
A sender will send a binary string to a receiver meanwhile he encrypt the digits. You are given a encrypted form of string. Now, the receiver needs to decode the string, and while decoding there were 2 approaches.

First, receiver will start with first character as 0; S[0] = 0, P[1] = S[1] + S[0], P[2] = S[2] + S[1] + S[0] and so on.

Second, Receiver will start with first character as 1; S[0] = 1, P[1] = S[1] + S[0], P[2] = S[2] + S[1] + S[0] and so on.

You need to print both the strings, after evaluation from both first and second technique. If any string will contain other that binary numbers you need to print NONE.

- 0of 0 votes
Given a normal die and a blank die. Fill in the blank die such that probability of sum of the number from both die is same for all the resulting sum and sum has a range from 1 to 12

- 0of 0 votes
Given a pond where all the stones are lined at a distance of one unit (C in each row and there are R such rows), each stone has a special value which denotes the length of the jump the frog can make i.e if frog is on stone (x,y) and value is k then frog can jump to (x+dx,y+dy) where dx+dy=k and frog doesn’t leave the bounds.Find the min number of jumps to reach the stone at (R,C).

- 0of 0 votes
Given a lane where there are various houses each containing a fixed amount of gold. Now a robber has to rob the houses such that when he robs a house the adjacent one cannot be robbed.Calculate the maximum amount of gold collected by him.

- 0of 0 votes
Given a network of roads connecting cities and capacity of each road(same for all roads)as well as their cost of repair(unique for each road) we are given number of buses(n) running between pair of cities using shortest path only. (Capacity of road= No of buses allowed on that road).

Unsafe roads are road where no of buses on the road > Capacity of the road.

Now given n we have to minimize the overall cost of all unsafe roads.

- 0of 0 votes
Given a review paragraph and keywords, find minimum length snippet from paragraph which contains all keywords in any order.

- 0of 0 votes
Design notification system (notify the customer with a message)

Client (delivery boy, company updates etc)

Services (Email, SMS, Watsapp)

Scaling up, fault tolerance & failure management

Flexible modifiability of clients & services

- 0of 0 votes
Dictionary of words is given

i.e. [“cat”, “dog”, “rat”, “catratdog”, “catter”]

Compound word: A word, which can be split into more than 1 valid words

get compound word, with longest string length.

- 0of 0 votes
N people are there.

knows(A,B) return true if A knows B, else false.

Celebrity: A is called a celebrity

If A knows none

Everyone knows A

Get celebrity, with less number of knows() method usage.

- 0of 0 votes
You are given a catalog of books, which have following attributes.

Name

Author

Publisher

Publish year

Category

Price

Count (sold)

Implement following APIs on top of this catalog

addBookToCatalog(Book)

searchBook(by partial book name/author)

getMostSoldBooks(by author name/category, limit)

Expectations:

Maintain DB on memory

Code should be readable. Design, handle naming convention,handle exceptions & should be running

- 0of 0 votes
Find last cell visited in 2D matrix traveresed in Spiral Fashion

- 0of 0 votes
Design an online poker game.

- 0of 0 votes
Given a server with a stack with some initial state say 1 Users can modify the stack using regular ops eg push 2 , pop etc and each op causes a version change. i.e version 1 : 1 , version 2 : 2,1 , version 3 : 3,2,1 , version 4 : 2,

You have to design it s.t person can ask for any version of the stack.

Hint : keep copies every k times and keep the ops in an nonvolatile memory

- 0of 0 votes
Given any language , you use libraries , which might use more lib etc . Find the order of building the libraries

- 0of 0 votes
Given two unsorted arrays A and B in which B can accommodate in A

How will you merge the two arrays.

- 0of 0 votes
Design a book catalog search (api’s were given for the search,full needs to be implemented as running application)

- 0of 0 votes
A solution was required to make a fantasy league with some budget allocated. Players will have some score/rating and the cost of player. Maximum score was to be achieved with eleven players.

- 0of 0 votes
A library for game 2048 was to be designed. The game can have constraints/variations which shall be defined by the game designer. The variations can be adding same numbers or adding Fibonacci numbers etc. APIs were to be exposed to the game designer.

- 0of 0 votes
Write down code in any language for a simple employee hierarchy which has 3 types of employees.

1. CEO

2. Manager

3. employee

Where an employee can have only 1 mgr, and a mgr has 1+ employees.

We were asked to input employee details(name ,id, salary,rating etc) in any order (employees might be input before his manager), create the hierarchy and implement these functionality:

1. Print hierarchy given any employee/mgr/ceo (used an n-ary tree + hash table)

2. Given a bonus and performance rating of each employee divide it to the lowest level employees(in the hierarchy ) in the ratio of their rating. i.e 100 divided among 2:3 is 40 and 60. and print the bonus of each ( simple recursive solution)

3. Top 10 employees with ratio of bonus:salary (used maxheap)

- 0of 0 votes
Given a login page come up with all possible test case from login API point of view and UI point of view.

- 0of 0 votes
--Suppose that we have an array of m by n size. Each element is binary, so it can either be 1 or 0. Design an algorithm that for a given array, the return is a set arrays containing the nodes that are adjecent to each other.

For example:

1 2 3 4 5 6 7 8

---------------

1|0 0 0 0 0 0 0 1

2|0 0 0 0 1 0 0 1

3|0 0 0 1 0 0 0 0

4|0 1 1 1 1 0 0 0

5|0 0 0 0 1 0 0 0

Returns:

Array1 {(8,1) (8,2)}

Array2 {(5,2) (4,3) (2,4) (3,4) (4,4) (5,4) (5,5)}