problem link>
my code>>
can u tell me why my greedy approach failing
*** considering I am using greedy from the back side
problem link>
my code>>
can u tell me why my greedy approach failing
*** considering I am using greedy from the back side
Hey , overall time complexity of your code is coming O(n*k) because of these two loops,
try to do it Monotone Queue. standing at ith position try to figure out from which index j you will get maximum score so that you come at i from that jth position. Here j can be anywhere between [i-k,i)
video for reference -> https://www.youtube.com/watch?v=W8N8EeWDwKs&ab_channel=LeadCoding
in that case why I didnt get TLE?
if your are getting WA then the concept will be wrong.
try for this test case:
[1,-5,-20,4,-1,3,-6,-3]
5
expected answer will be 5
yours is giving 2
bhaiya How to find these test cases like I find it difficult to get those where my soln fails
try for random input if you aren’t good at designing test cases. Doing it multiple times you will be good at it. All the best !
okay bhaiya got that
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.
I HAVE WRITTEN THIS DOUBT TWICE BUT NOBODY PICKS WHY ???
problme link>>
my code
my code failing on big test cases plz help
Don’t know, i can help you to solve your course problems, at max leetcode problems. You can post a doubt whenever you need help regarding them.
aman yadav bhaiya used to take my all doubts and I guess doubts are doubts . And problems on interviewbit are really good and mostly asked in interviews so I guess doing it will also enhance your skills
You can post a new doubt as i can’t see your doubt in active section, so if one knows the problem can help you with it.