Your friend for GRE words and Vocabulary. Find here

Monthly Archives: October 2012


Max Concatenate

By |October 15th, 2012|

Given 2 strings, return the max number that can be formed by joining them.
For example, if the strings are:
45 and 456
2 numbers are possible
The output should be

int main(int argc, char * argv[]){
int a, b,min,i;
char *st;
 a= strlen(argv);
 b= strlen(argv);
 min= a < b ? a : b ;

     if (argv < argv){
             st=  strcat(argv,argv);

              return 0;



By |October 14th, 2012|

Bob has n heap(s) of gravel (initially there are exactly c piece(s) in each). He wants to do m operation(s) with that heaps, each maybe:

adding pieces of gravel onto the heaps from u to v, exactly k pieces for each,
or querying “how many pieces of gravel are there in the heap p now?”.

Help Bob do […]

Rectangles Counting

By |October 14th, 2012|

Given N separate integer points on the Cartesian plane satisfying: there is no any three of them sharing a same X-coordinate. Your task is to count the number of rectangles (whose edges parrallel to the axes) created from any four of given points.
There are several test cases (ten at most), each formed as follows:

The first […]

Number Game Revisited

By |October 14th, 2012|

Alice and Bob play the following game.They choose a number N to play with.The runs are as follows :

1.Bob plays first and the two players alternate.

2.In his/her turn ,a player can subtract from N any prime number(including 1) less than N.The number thus obtained is the new N.

3.The person who cannot make a move in […]

Graphs in Euclidean Space

By |October 14th, 2012|

The Chef is a bit tired of graphs. He has spent far too many days calculating shortest paths, finding bipartite matchings, minimum cuts, and optimizing over NP-hard problems. He needs a break. Unfortunately for him, the food services industry doesn’t take breaks. Once again, the Chef has to navigate through an undirected graph to keep […]

Generalized Independent Sets

By |October 14th, 2012|

Given a graph G on nodes V with undirected edges E, an independent set X is a subset of V such that no edge in E has both endpoints in X. Finding the size of the largest independent set in a graph is currently a very difficult problem.

Consider the following generalization of an independent set. […]

Central Point (April 2011)

By |October 14th, 2012|

Given a set of N integer points on the Cartesian plane. Your task is to find an integer point satisfying its sum of distances to N given points (S) is minimum.
There are several test cases (fifteen at most), each formed as follows:

The first line contains a positive integer N (N ≤ 2,000).
N lines follow, each […]

Call by address vs Call by reference in C++ (Most Relevant answer)

By |October 13th, 2012|

Call by Address
In call by address, instead of passing the actual values of the actual argument we pass addresses of actual values. Whenever we deal with addresses, we must know how to handle them. That’s why before discussing call by address, we will briefly discuss pointers that handle addresses.
Introduction to Pointers
We all know that the […]

IEEE 754 analyzer

By |October 12th, 2012|

Nice tool to clear your doubts regarding IEEE 754 representation

Four People on a Rickety Bridge

By |October 9th, 2012|

Question: Four people need to cross a rickety bridge at night. Unfortunately, they have only one torch and the bridge is too dangerous to cross without one. The bridge is only strong enough to support two people at a time. Not all people take the same time to cross the bridge. Times for each person:  1 min, 2 mins, 7 mins and 10 mins. What is the shortest time needed for all four of them to cross the bridge?


Globe Walker puzzle

By |October 9th, 2012|

Question: How many points are there on the globe where, by walking one mile south, then one mile east and then one mile north, you would reach the place where you started?

Gold for 7 Days of Work

By |October 9th, 2012|

Question: You’ve got someone working for you for seven days and a gold bar to pay them. You must pay the worker for their work at the end of every day. If you are only allowed to make two breaks in the gold bar, how do you pay your worker? (Assuming equal amount of work is done during each day thus requiring equal amount of pay for each day)


100 Prisoners in Solitary Cells

By |October 9th, 2012|

100 prisoners are stuck in the prison in solitary cells. The warden of the prison got bored one day and offered them a challenge. He will put one prisoner per day, selected at random (a prisoner can be selected more than once), into a special room with a light bulb and a switch which controls the bulb. No other prisoners can see or control the light bulb. The prisoner in the special room can either turn on the bulb, turn off the bulb or do nothing. On any day, the prisoners can stop this process and say “Every prisoner has been in the special room at least once”. If that happens to be true, all the prisoners will be set free. If it is false, then all the prisoners will be executed. The prisoners are given some time to discuss and figure out a solution. How do they ensure they all go free?


“Is Your Husband a Cheat?” Puzzle

By |October 9th, 2012|

A certain town comprises of 100 married couples. Everyone in the town lives by the following rule: If a husband cheats on his wife, the husband is executed as soon as his wife finds out about him. All the women in the town only gossip about the husbands of other women. No woman ever tells another woman if her husband is cheating on her.  So every woman in the town knows about all the cheating husbands in the town except her own. It can also be assumed that a husband remains silent about his infidelity. One day, the mayor of the town announces to the whole town that there is at least 1 cheating husband in the town. What do you think happens?


Clock Hands

By |October 9th, 2012|

How many times a day do the minute and hour hands of a clock overlap?