ques : https://practice.geeksforgeeks.org/problems/subarray-with-given-sum/0/?track=md-arrays&batchId=144
code : https://ide.codingblocks.com/s/218776
not able to understand where its wrong
ques : https://practice.geeksforgeeks.org/problems/subarray-with-given-sum/0/?track=md-arrays&batchId=144
code : https://ide.codingblocks.com/s/218776
not able to understand where its wrong
u were inputting the array as 1 based indexing, while solving it further on 0 based indexing
first accessing arr[rptr] with rprt = 0 is wrong, it takes garbage
secondly, if u are solving for 1 based index, the loop should go till n and not till n-1
only this i have changed and your solution passes the test cases on gfg
if your doubt is solved, please mark it as resolved
thanks a lot… i am able to solve it now