X
Submit Question

Interview Questions

View By:

Q1 Puzzle "Parlor "

Beautiful You Pvt. Ltd. owns several parlors. Research has shown that if a customer arrives and there is no staff available to service them, the customer will turn around and leave, thus costing the company a sale. Your task is to write a program that tells the company how many customers left without getting any service.

Problem Definition:

The samples below consists of function calls for 4 parlors. Function call for each parlor contains a positive integer, representing the number of staff in the parlor, followed by a sequence of uppercase letters.

Letters in the sequence occur in pairs. The first occurrence indicates the arrival of a customer; the second indicates the departure of that same customer. A customer will be...
show more

Unkown  | Programming puzzle  |  Level - 2

Answer Write Code Visit Question Page

Q2 PONY

Discord is in trouble for causing discord, so he is trying to escape from Equestria. He's arrived at the port, and he doesn't care what boat he gets on, he just wants to get out. He can see the boat schedule, where he sees that N boats are arriving today,

boat 1 arrives any time within a_1 minutes

boat 2 arrives any time within a_2 minutes

...

boat N arrives any time within a_N minutes (uniform distribution)

Tell discord the expected number of minutes he needs to wait for a boat to arrive.

For example If n=3 , and there arriving times are 49,50,51 respectively then expected number of minutes would be 12.495000 . Thats all I know .

Google  | Algorithm  |  Level - 3

Answer Write Code Visit Question Page

Q3 Log parser

Each time a visitor requests a page from our website, our webserver writes a log entry recoding the visitor's identity and the kind of page requested. Entries are written in chronological order to a plain-text file, with one entry per line. The format of each entry is:

user-id page-type-id

User IDs are arbitrary strings that uniquely represent a given user; if a user visits multiple pages, each log entry will have the same user ID. Page type IDs are arbitrary strings that uniquely represent a given kind of page on our site, such as the homepage, a product detail pages, or the shopping cart. Tons of users visit our website, but there are only a few dozen types of pages.

We can use our weblogs to answer questions about user b...
show more

Amazon  | Algorithm  |  Level - 3

Answer Write Code Visit Question Page

Q4 SDET Interview

1) Print All k size subset of given array of size n

Walmart  | Arrays, Algorithm  |  Level - 1

Answer Write Code Visit Question Page

Q5 Reverse adjacent nodes in a linked list

Reverse the adjacent nodes in a linked list If the nodes of a linked list are as follows 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 then after reverse they should be 2 -> 1 -> 4 -> 3 Here the number of entries are odd hence the last link is not reversed. If number of nodes are even then last node should also be reversed.

Google  | Linked List  |  Level - 1

Answer Write Code Visit Question Page

Q6 Print the binary tree using Breadth First Traversal but reverse the elements of every nth breadth

Imagine we have a binary tree having following structure. Please see the structure at following link

![http://mathworld.wolfram.com/images/eps-gif/CompleteBinaryTree_1000.gif]

We need to print the tree using breadth first traversal but need to reverse the elements of every nth breadth from a provided starting point. I have used additional stack with queue to get the desired functionality. It will be more easier for users to understand the problem after running the code and seeing the output.

Google  | Trees and Graphs  |  Level - 1

Answer Write Code Visit Question Page

Q7 Find the path in 2 Dimensional array which has the most 1

You have a m*n size 2 Dimensional Array filled with either 0 or 1. You have to figure out the path which contains the most 1 when starting from arr[0][0]. You can only traverse down or right.

For ex: If array has values

1 1 0 1 0 1 1 0 1 0 0 1

So here the path containing max 1 is arr[0][0], arr[0][1], arr[1][1], arr[1][2], arr[1][3] and arr[2][3]

Google  | Arrays  |  Level - 2

Answer Write Code Visit Question Page

Q8 Balanced BST

Find two elements in balanced BST which sums to a given a value. Constraints Time O(n) and space O(logn).
      6
 3         8

1 4 7 12

sum = 16 o/p should be 4 and 12

Google  | Algorithm  |  Level - 2

Answer Write Code Visit Question Page

Q9 Staves

You want to create a staff to use in your martial arts training, and it has to meet some specific requirements.
  1. You want it to be composed of two smaller staves of equal length so that you can either use it as a single staff or as two smaller ones.

  2. You want the full sized staff's center of gravity to be exactly in the middle of the staff.

You have a very, very long branch from which you can cut the pieces for your staff. The mass of the branch varies significantly throughout it, so you use just any two pieces of the same length. Given a description of the mass throughout the branch, determine the longest staff you can make, then return three integers on a single line, the first two indicatin...
show more

Facebook  | Algorithm  |  Level - 3

Answer Write Code Visit Question Page

Q10 URL Detection

MS Word has the inbuilt logic to detect the url when user writes to any document. MS Word application detects the url typed by user and hyperlinks it. Write a code to:

1) Detect url assuming that MS Word engine streams the characters to your function BOOL DetectURL(UCHAR chUserCharEntry) 2) Once #1 is completed then execute the url from IE

Google  | Algorithm  |  Level - 2

Answer Write Code Visit Question Page