How to approach this:-
Emphasize on Word "if and only if"
Read all options carefully ..eliminate the wrong ones.
A. May Correct but due to if and only if Check remaining options.
C. False . Example:->5,5,4 it wont return 1.(still optionA may correct).
D. False. Example:->> 8,2,10 it wont return 1(still option A may correct).
B.Example:->> 1,1,2 it returns 1
So here Option A becomes wrong Now So option B is correct.
(Check another large list also 1,2,2,3,3 still returns1 So finally Option B is Ans.)