Asadullah Ansari

Build-Up Your Problem Solving Skill : Specially Using By C/C++/Data Structure Puzzles/New Technique Algorithm Design/ Understanding New Technology

Posts Tagged ‘Problem Solving Skill’

Freeze your mind!!!!

Posted by asadullahansari on August 22, 2008

A bank has a collection of n bank cards that they�€™ve confiscated, suspecting them of being used in a fraud. Each bank card corresponds to a unique account in the bank. Each account can have many cards corresponding to it, and we�€™ll say that two bank cards are equivalent if they correspond to the same account. The only way to say 2 cards are equivalent is by using a high-tech �€œequivalence-tester�€� that takes in 2 cards, and after performing some computations, determines whether they are equivalent.

Their question is the following: among the collection of n cards, is there a set of more than n/2 of them that are all equivalent to one another? Assume that the only feasible operations you can do with the cards are to pick two of them and plug them in to the equivalence tester.
Solve it in O(n) complexity.

Posted in Queries & Answers | Tagged: , | Leave a Comment »