Can you please tell me where I am going wrong

Let me confirm, you are trying to binary search on answer and check, right?

Let me confirm, you are trying to binary search on answer and check, right?

yes

Set s as the maximum element in the array, as you can’t get a value less than it.

I still can’t pass those test cases.

Please share the updated code.

Largest element not the last.