Prata Spoj Problem


This is my code for the problem, but my answer is not coming right. Please check and help

@Tapan YOu cannnot sort the array. Order will change.

Removed the sort function, still the same problem

Yeah your solution is wrong. See this solution I wrote

My logic is right?
Can you recommend changes in my code please?

@Tapan Make some necessary changes. Since you are not sorting the array you cannot take the max element as the last of the array. YOu have to find the max element then do the binary search

That’s why I sorted the array! Sir provided the similar approach in the video.
Is the isPossible function correct?

@Tapan No I dont think the function is correct. Try to write a correct function yourself as you will learn to implement it yourself.

@Tapan Try to write the code yourself dont watch the video as it will not allow you to think yourself and you will not learn.

Have you checked the video of Prateek bhaiya regarding this problem? Sorry if I am sounding rude, but I am pretty sure the logic is correct, it’s just that I am missing out on code.
Also the video doesn’t provide with the code, just the logic.

@Tapan I haven’t seen the video As this is a simple binary search problem try to code the logic yourself.

The code I sent isn’t a copied one. I have coded it myself only sir! The logic used to code is the one told by sir.
I checked your code but am not able to understand it clearly! I coded as per the logic suggested by Prateek Bhaiya!
Can you go through my code and see if it can be rectified?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.