InterviewSolution
Saved Bookmarks
| 1. |
There are `n`locks and `n`matching keys. If all the locks and keys are to be perfectly matched, find the maximumnumber of trails required to open a lock. |
|
Answer» The maximum number of trials needed for the first key is n. For the second key, it will be n-1. Now, for the rth key, the maximum number of trials needed is n-r+1. Thus, the required answer is `n+(n-1)+..+1=(n(n+1))/(2)` |
|