question link
my leetcode sbmission is passing 63 cases outof 93
can anyone tell me correct my approach i have two pointer approach
question link
my leetcode sbmission is passing 63 cases outof 93
can anyone tell me correct my approach i have two pointer approach
Hey @shivammishra20121999 can you please tell me about the approach you are using so that I can easily debug it for you.
@ hey are u there you have seen my code
Hey @shivammishra20121999 I am sorry cause I won’t be able to provide you with my phone number. You can explain it here and I’ll try my best to debug it for you.
@mr.encoder
i have used sliding window approach
1.i keep adding the elements to sum till the time it is less than x
2.if sum >=0 then i shrink my window size from left to get the shortest length
Okay I got it. Have you used deque as a data structure or have applied using array?
Hey @shivammishra20121999 it can be done but when you uses deque, it will take care of side cases on it’s own. Are you familiar with deque concept?
Hey @shivammishra20121999 the sliding approach you have used seems to be appropriate. Give me some time I’ll debug this code as per your requirements and let you know your mistake. Till then you can do your next question. When I’ll debug it, I’ll reply to your query here so that you can submit it 
Right now I am taking few more doubts. I’ll debug it in between 6-7. Will that work for you?
Okay I’ll debug it till 5:30, just be patient till then,okay?
hey friend i got your mistake, take this test case for example :[84,-37,32,40,95] & 167
here we first go in this loop
while (curr_sum < x && end < n)
{
// Ignore subarrays with negative sum if
// x is positive.
if (curr_sum <= 0 && x > 0)
{
start = end;
curr_sum = 0;
}
curr_sum += arr[end++];
}
here,
cum_sum is 0, and x is also greater then 0 so we go in if statement, so csum becomes 84.
cum_sum is 84, and x is also greater then 0 so we don’t go in if statement, so csum is 47.
cum_sum is 47, and x is also greater then 0 so we don’t go in if statement, so csum is 79.
cum_sum is 79, and x is also greater then 0 so we don’t go in if statement, so csum is 119.
cum_sum is 119, and x is also greater then 0 so we don’t go in if statement, so csum is 214.
After that we goes in this condiion
// If current sum becomes greater than x.
while (curr_sum >= x )
{
// Update minimum length if needed
if (end - start < min_len && curr_sum>=x && start<n)
{
min_len = end - start;
}
// remove starting elements
curr_sum -= arr[start++];
}
therfore giving you output as 5(6-1), your approach is partially right but won’t get fully accepted. Try to approach it using deque 
Try to understand from this post
A well explained approach, if still get struck into it. You can ask me 