Can anybody tell me why am i getting WA in cachehit problem

https://www.codechef.com/viewsolution/34624471

Thank you for the help!

Sir,it would be better if you try to explain your logic here…will help me to debug faster
Also,I feel you can try to look at other’s code to get a better and easy approach than yours.
Thanks…

Set low and high with -1 at first.
I mean low=-1, high=-1
Because at first there is no cache.

1 Like

Thank you it worked. But can you elaborate on how did it make the difference? Like if I am starting from range 0 to b-1 and making count 1 in starting only then also it should work normally?

When a cache request happen between the interval 0 - b-1 for the first time, what will happen? Count should be incremented by 1.
But if you already set cache range at 0 - b-1 count will not be incremented. Tell me if you don’t understand yet.

Oh yes. Thank you!