Here answer is D) None of the above.
Size of array is k & Array should contain all no from 1 to k-1. So there are k-1 no that must be there. Once we fill up k-1 places with 1 to k-1 no, we get one extra space.
We can put any No X there ! (Not necessary to be in 1 to k-1, it is not said that array contains ONLY no from 1 to k-1)
Last = (k * k - 1 ) /2;
value = sum of 1 to k-1 + X = (K * k-1 ) / 2 + X
Value - Last = X
So answer is D.
It seem like B is correct, but it is not so. As we do not need to repeat any no, we can take no outside of given range 1 to k-1 !
Value - Last = Extra no