## Brain Teasers Interview Questions

- 2of 2 votes
Given a string (1-d array) , find if there is any sub-sequence that repeats itself.

Here, sub-sequence can be a non-contiguous pattern, with the same relative order.

Eg:

1. abab <------yes, ab is repeated

2. abba <---- No, a and b follow different order

3. acbdaghfb <-------- yes there is a followed by b at two places

4. abcdacb <----- yes a followed by b twice

The above should be applicable to ANY TWO (or every two) characters in the string and optimum over time.

In the sense, it should be checked for every pair of characters in the string.

- 0of 0 votes
If one and a half teenagers, eat one and a half pizzas in one and a half days, how many pizzas can 9 teenagers eat in 3 days

- 0of 0 votes
There is a two storey home. We have three switch on the first floor and three rooms on the second floor. You can go upstairs only once and can touch switches only one. How will you find out which switch is for what room?

- 0of 0 votes
The Question is to find 4 numbers between 1 and 40, so that you can get all the numbers between 1 to 40 by doing either of operation below.

1) Either any of the four number itself.

2) creating an expression by combining among the four number, with either addition or subtraction.

For example suppose we have to find four numbers so that we can get numbers between 1-30.

The answer to above question is 1,3,6,20.

- 0of 0 votes
You stand in one corner of a large room, and your assistant is in its opposite corner. In front of the assistant is a 4-corner table, with a coin in each of the 4 corners. Your objective is to get the coins to be all heads or all tails. When that happens, the coins start jumping up and down; so, you'll know for sure when it happens. What you can do is to tell your assistant: (a) flip one coin; (b) flip two coins on a side of the table; (c) flip two coins on a diagonal of the table. You can't tell the assistant which coin, which side, or which diagonal to use. You can either think of your assistant as being extremely dumb, or that the table is being constantly rotated by external forces. What is the sequence of commands that you should give to your assistant to make sure the coins start jumping up and down?

- 1of 1 vote
Distributing Medals It's the medal distribution ceremony. 10^6 police officers, numbered from 1 to 10^6, are standing in a line. There are N (1<=N<=1000) iterations of medal distribution. In iteration i (0 < = i < N), count[i] ( 1 < = count[i] < = 100) medals are given to all officers from from[i] to to[i] ( 1 < = from[i] < = to[i] < = 10^6 )

If we sum up the number of medals received starting from the first officer, who would be the first officer for which the cumulative sum exceeds a given medal count THRESHOLD ( 1 < = THRESHOLD < = 10^9 )?

Input/Output Specifications Input format:

You are given 5 inputs:

input1 = N, the number of iterations

input2 = count, the array of medal counts in each iteration

input3 = from, the array of starting indices in each iteration

input4 = to, the array of ending indices in each iteration

input5 = THRESHOLD, the medal count threshold

Output format:

An integer, representing the number of the first officer such that the cumulative sum of medals starting from the first officer upto this officer exceeds THRESHOLD. The output should be -1 if such an officer does not exist.

- -1of 1 vote
Distributing Medals It's the medal distribution ceremony. 10^6 police officers, numbered from 1 to 10^6, are standing in a line. There are N (1<=N<=1000) iterations of medal distribution. In iteration i (0 < = i < N), count[i] ( 1 < = count[i] < = 100) medals are given to all officers from from[i] to to[i] ( 1 < = from[i] < = to[i] < = 10^6 )

If we sum up the number of medals received starting from the first officer, who would be the first officer for which the cumulative sum exceeds a given medal count THRESHOLD ( 1 < = THRESHOLD < = 10^9 )?

Input/Output Specifications Input format:

You are given 5 inputs:

input1 = N, the number of iterations

input2 = count, the array of medal counts in each iteration

input3 = from, the array of starting indices in each iteration

input4 = to, the array of ending indices in each iteration

input5 = THRESHOLD, the medal count threshold

Output format:

An integer, representing the number of the first officer such that the cumulative sum of medals starting from the first officer upto this officer exceeds THRESHOLD. The output should be -1 if such an officer does not exist.

- 0of 0 votes
Given an array[0, n-1], each number of the array is positive int. Your task is adding the operators,"+","*", "(",")" (add, multiply, parenthesis) to maximize the result . The position in the array is Fixed.

For example, "2,1,1,2", you can get (2+1)*(2+1)=9.

Follow up, if the number may be negative , how to solve it ?

- 0of 0 votes
Estimate the number of USPS boxes (i.e. ones at home address and NOT P.O. Boxes) in the U.S. You are not given USPS data, of course.

- 0of 0 votes
Design a phone book such that fields are searchable with name , with number. Later enhanced teh question asking searchable with address as well.

- 0of 0 votes
I've heard this from someone, guess it is not the full question but this question is quite familiar:

Given some kind of operating system that run Tasks. Every task comes with a certain time it should run. For example first task need to run 15 seconds, after 2 seconds comes another task that need to run another 30 seconds, after 7 seconds comes another task need to run another 2 seconds, etc.

You have a scheduler that runs every second and check which task need to be run and run them.

You don't have system clock and need to find a solution without it.

How would you implement it?

- 3of 3 votes
A man goes to a hardware shop and asks for price of an item. The shop keeper replies that the item is "one for $1".

The man gives the shop keeper "$3 for 600". What did the man buy for his newly painted house?

- 1of 1 vote
Generate all Kaprekar Number (refer Wiki for Kaprekar number's definition) from 1 to 999999.

I gave a brute force approach of generating all number in the range and checking if it is Kaprekar or not.

- 3of 3 votes
Given three points in a 2D plane with their (x, y) coordinates say if the origin lies inside the triangle formed by the three points.

- 3of 3 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?

- 1of 1 vote
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.