Question: You are given n keys and n locks. Each key can unlock precisely one lock. The difference in size between the keys is too small
You are given n keys and n locks. Each key can unlock precisely one lock. The difference in size between the keys is too small for you to notice if you try comparing two keys directly. Similarly, upon visual inspection, you cannot compare two locks and determine which keyhole is larger or smaller. When you use insert a key in a lock, if the key is too small, it will go into the keyhole, but the lock will not unlock. If the key is too large for the lock, it will not t into the keyhole. A key will only unlock a lock if it is the correct size. Give the fastest algorithm that you can (in the worst case) to match all keys to their corresponding locks.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
