## Brain Teasers Interview Questions

- 2of 2 votes
Given a random generator rand(5) which generates numbers between 0 to 4. How do u generate numbers between 0 to 6, I.e. Implement rand(7).

- 0of 0 votes
Unable to get what exactly the Question Is?

so What is the whole logic behind this question .It seems to be complete Math problem to me.

There is a Grasshopper in a tropical forest. The grasshopper can jump only vertically and horizontally, and the length of jump is always equal to x centimeter. A GRasshopper has found herself at the center of some cell of the chess board of the size pxq centimeters(each cell is 1x1 centimeters). She can jump as she wishes for an arbitrary number of times, she can even visit a cell more than once. the only restriction is that she cannot jump out of the board.

The grasshopper can count the number of cells that she can reach from the starting position(x,y). Let's denote this amount by dx,y. your task is to find the number of such starting position(x,y), which have the maximum possible value of dx,y

Input

The integer array contains three integers p,q,x

p= length of the board

q= width of the board

x=length of the grasshoppers jump.

Output

Output the only integer - the number of the required starting position of the Grasshopper

Example

input 2 3 1000000

output 6

input 3 3 2

output 4

Regards,

JSD

- 1of 7 votes
Given an excel column number convert it to excel column alphabet and reverse.

Example : If column number(starts from 0) = 26 : Column alpha = AA.

- 0of 0 votes
"How would you find the number of gas stations in the United States?"

*You cannot look up any concrete information (like the average number of gas stations per state), but you need to yield an accurate answer.

- -1of 1 vote
They have given some flowchat questions in thought works ... how to solve these questions can anybody explain for all the questions....?

http://placement.freshersworld.com/placement-papers/ThoughtWorks/Placement-Paper-Whole-Testpaper-29732

- 0of 0 votes
You are trying to cook an egg for exactly 15 minutes, but instead of a timer, you are given two

ropes which burn for exactly 1 hour each. The ropes, however, are of uneven densities â€“ eg,

half the rope length-wise might take only 2 minutes to burn?

- 0of 0 votes
Two container of 5 L and 3 L are given. Then are is 9.5L water given you need to make 4L water with minimum attempts and water wastage.

- 1of 1 vote
A Contracter is doing work for 7 days at your home, you need to pay him 7000$ in total. Every day you need to pay him 1000$ only .. To Pay him you have a gold plate wortjh 7000$ , but you can cut it only twice

- 0of 0 votes
How would you structure the game of life (classes, functions etc...)? How would you structure the board if it was played on a sphere?

- 0of 0 votes
Find the degree of separation between two people (e.g. LinkedIn's connected feature)

- 0of 0 votes
A subscriber is allowed to make a certain number of telephone calls for a lumpsum charge of Rs.300. Beyond that, he is charged at a certain rate per call. Two subscribers together make 1400 calls, and were charged Rs.425 and Rs.925 respectively. If a single person had made all of the 1400 calls he would have been charged Rs.1550. How many telephone calls are allowed for the first Rs.300?

option

a)300

b) 350

c) 400

d) 450

- -4of 4 votes
Write a function called FooBar that takes input integer n and prints all the numbers from 1 upto n in a new line. If the number is divisible by 3 then print "Foo", if the number is divisible by 5 then print "Bar" and if the number is divisible by both 3 and 5, print "FooBar". Otherwise just print the number.

for example FooBar(15) should print as follows:

1

2

Foo

4

Bar

Foo

7

8

Foo

Bar

11

Foo

13

14

FooBar

I know, easy right? ;)

- 3of 3 votes
You have three jars filled with candies. One jar is filled with banana candies, one jar is filled with lemon candies and one jar has a mix of both. All the jars are mislabelled (i.e. all the jars have wrong labels about what kind of candies they contain).

All the candies look very similar in shape, size and color and they even smell the same. The only way to distinguish them is by tasting.

You have to eat one and only one candy to determine the correct jar labels. You can eat that one candy from any jar you want as long as you eat only one in total.

- -4of 4 votes
design an alarm clock for a deaf person.

- 0of 2 votes
3 fruit baskets having apple, orange and mix. all labeled wrong. with only one sample taking from one basket but not peeking find out which basket has which one.

- 0of 8 votes
9 identical balls. one ball is heavy. find the heavy ball with only 2 measurements ........ dead easy.

- 0of 0 votes
You have perfect cubical blocks (i.e. each of the blocks has 6 sides)

You have to make a calender display using those two cubes. So the task is to display the numbers 1 through 31 using the two cubes. For example you would make the date 13th by writing '1' on one cube and '3' on the other.

Only one digit can be written on each face of both the cubes. So there should be 6 numbers printed on each face of the two cubes.

How would you split and write the numbers on the two cubes such that all the numbers from 1 through 31 are displayed using them?

- 5of 7 votes
What is the minimum representation in bits of two positions on an 8x8 chessboard?

- 3of 3 votes
There is a fictional company called fooBar in fooLand. The CEO of fooBar, fooMan, directs all managers to minimize the total hike that they give to employees, while ensuring that the hike is fair to them. Usually, this is done by giving more hike to employees who are rated better. So, for example, if an employee is rated 2 and is given hike 3x, an employee rated 3 should be given a hike greater than 3x. Hikes are always in multiples of x only and the minimum hike to be given to any employee is x.

This year, however, a wicked manager, barMan comes up with a brilliant strategy. He assumes that each employee would get to know the hike of only the two employees who sit next to him (one on the left, one on the right). And therefore, he reasons(using whole of his analytical left brain), that as long as he could make hikes fair for each employee with respect to the two employees that sit next to him, he would fulfill the dual objective of being "fair" as well as minimizing the total hike given. Just for clarification, the employees of each team sit in one big line.

barMan hires you to calculate the hike to be given to each employee. Over to you. You are supposed to come up with the total hike number that will excite barMan and make him roll on the floor laughing. You are given that no two employee sitting next to each other would have a common rating.

Input:

The order of rating of each employee should be in the order in which they sit. First line will be the value of x. The second line will be the number of employees 'n'. The next 'n' lines specify the rating of each employee. Rating can be integers from 1 to 105. (weird, right?)

1 <= n <= 105.

1 <= x <= 104.

Sample input 1:

10

4

1

4

6

2

Output:

70

Why?

If we have the hikes as first employee gets 10, second gets 20, third gets 30 and fourth gets 10, we satisfy all our constraints.

- 0of 0 votes
How would you weigh an aeroplane

- 0of 0 votes
Given a preorder sequence from a Binary Tree, how many unique trees can be created from this? (They want a recurrence relation and start with the easy cases):

T(0) = 1

T(1) = 1

T(2) = 2

What is T(N) ?

- 2of 2 votes
A lot of transistors contains 0.6 percent defectives. Each transistor is subjected to a test that correctly identifies a defective but also misidentifies as defective about two in every 100 good transistors. Given that a randomly chosen transistor is declared defective by the tester, compute the probability that it is actually defective.

- 4of 4 votes
given a matrix of size m * n, place k students in such a way so that cheating in an exam could be minimized

- 2of 8 votes
Given one egg and a building with infinite number of floors. Find out minimum number of throws at which (least) floor egg will break, if thrown?

I said we have to start at floor 1 and keep incrementing and testing by moving 1 floor up. Then he said optimize it by minimizing no of throws. I could not find more optimal way. I told him that I know with problem with 2 eggs and finite floor building.

Then, he told me that now lets there are 2 eggs and infinite floor building, find minimum no if throws required to find least floor at which egg breaks.

I still could not do that for infinite floors.

- -3of 5 votes
You are given two eggs of same size and shape, there is a 50 stories building. you have to find the toughest egg in minimum number of attempts. Once egg is broken you won't be given a replacement.

- 4of 4 votes
100 doors are closed , In first pass i open all of them , in 2nd pass i toggle every 2nd door , in 3rd pass i toggle every 3rd door , i continue it till 100th pass .. find all the doors that will remain open after 100 passes.

- 4of 4 votes
find the sum of all 4 digit numbers formed from 1 , 2, 3, 4 whithout rep .

- 1of 5 votes
This was the question of two buckets of 3 and 5 litres each. Now measure four litre. I had given 2 solutions but still he wanted 3 solution.

1st soln: fill 3 litre and then interchange in various ways to get 4 litre.

2nd soln: fill 5 litre and then interchange in various ways.

do you have any soln other than this.

- -2of 4 votes
need to implement a weather report functionality. user will provide the city name , need to return the weather report.

if weather station exists n functioning properly , will return the weather report of that station .

else ,

will return the nearest available weather station report.

interviewer looking for optimized manner.

looking for datastructures to stores the cities n algo to return the report.

- 1of 1 vote
you have a set of integers between 1 .. n in a random order with one of the numbers being repeated. find the best possible way (time and space) to obtain the repeating number.