SMARKET - getting wrong answer in binary search solution

april
long

#1

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.


#2

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.


#3

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


#4

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


#5

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


#6

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


#7

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


#8

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.


#9

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.


#10

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


#11

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: )


#12

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