Wrong solution for test case 4

what could go wrong ??

Hi Rohan, let me know your approach to the problem and we’ll discuss what could possibly wrong.

1 Like

My code - https://ide.codingblocks.com/s/141622

Read the given Example how i am implementing the dp table. Test case 4 is getting wrong

Hi, I read the code and I feel your approach is alright and is logically correct. However I am unable to understand why that particular test is failing, anyway as the question says N <= 10^5 and K <= N many tests can be built to TLE/MLE your code as it takes N*K time and space. i encourage you to think of an O(n) solution. I’ll try to find what exactly is failing and get back to you :slight_smile:

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.