SMARKET - getting wrong answer in binary search solution

I have written binary search solution for the question SMARKET.

Here is my solution Binary_Search_Approach
Only four of the total test cases passed. Someone please point out the error I have done . I have documented my code, that might help you to know the logic for the code.

Thanks in advance.

Try this test case-

Input
1
5 1
2 2 2 3 3
3 5 2
Your Output
0
Expected Output
1

I am a C++ user, not much into Java, so debugging that is kind of hard for me. Sorry for that.

1 Like

Yes, it is really good question.
But I am not sure that you can find the answer on this forum.
You should search the info on the professional websites.

assignment help

Seems like i won’t get any help… I am leaving this question now.

I recently wrote an essay about concept. It did perhaps not manage to end and purchased. If I study your write-up before here Hot-Essay.com

Thank you for always replying… but I am having a tough time finding the error.

Will you please give me some more test cases. Code is still failing.

How did you approach the problem? Things like what did you stored and things. What lines of code correspond to your query and tree building function? I can try giving a look if its really bothering you.

Actually I followed the logic that is provided in this video https://www.youtube.com/watch?v=1MY_hEpBXaI&t=2s .

This is basically a binary search approach. For that i have to make an array of b[ i have documented this in my code]. Then doing a binary search in the ArrayList index_dalo [ this is made using b array] using l and r.

@vijju are you there? can you point out the mistake, or give me some test case where my code fails?

Sorry bro, tried debugging your code for around 1 hour. Cannot get it now. I will have another look in morning (not feeling well atm. Sorry for that :slight_smile: )

Sorry dear, i tried my best. I couldnt catch the bug. Segment tree bugs arent easy to figure out.