First technical post!?

08 Dec

1. How will you find n largest pair (a[i], b[j]) from two sorted array A and B

What I mean is .. There are two arrays A and B of length N each and both the arrays are sorted in descending order … Now we need to find the N largest pairs (a[i]+b[j]) from A and B.

Simply putting it is same as finding all the possible n^2 (a[i]+b[j]) combinations of sums from both the arrays and sorting them and them give back the first N numbers. 😉

2. You are given 2 dice. One of the dice is numbered 1 to 6. What should the other die be numbered so that when you roll the two dice the probability of getting a sum in the range 1-12 is same i.e probability of getting sum 1,2,…..12 is equal.

Note: The sum should be only within the range 1 – 12, no other values are permitted.

1 Comment

Posted by on December 8, 2009 in Uncategorized


One response to “First technical post!?

  1. Naveen

    December 11, 2009 at 11:21 am

    looks like this is better..
    Like MERGE in merge sort,
    take every next two element and sum it. repeat this N times.
    MERGE method will put the elements in sorted order. In this case, get the bigger element of the 2 sets and find the next bigger element of the 2 sets. sum it up..u have highest sum in ur N elements(array in the answer). Do the same thing for remaining N-1 elemnts.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: