A good example of how including negative people in your life affects your mental health, from leetcode
@madhubabu3482Ай бұрын
Good one sir, I solved 850+ questions on leetcode with 350+ days streak Still selected for 3.5LPA in TCS Feeling sad but i am still motivated and consistent that i will do Big someday Thanks for posting videos regularly
@gui-codesАй бұрын
congrats man. don't worry it's the start. you will get to your goal. have faith and keep grinding.
@guddukumar-v8z5lАй бұрын
bhai konse college se ho.
@anshror2583Ай бұрын
Hey can you can share your linkedin ID
@anshror2583Ай бұрын
Congrats man celebrate every moment although your output is not equal to your effort but soon you will get to your goal
@malvado8267Ай бұрын
contest rating kitna hai?
@rishabhray7295Ай бұрын
you are doing good job and without any fumble and crystal clear in all your videos
@Aditya-qx7nfАй бұрын
Thnx bro, loved the approach. Solved the medium level one without thinking but couldn't solve when negtive numbers were involved
@wearevacationuncoverersАй бұрын
perfection at its peak. you are amazing
@KajalSinghshineАй бұрын
0:45 yes sir and these are those people who are themselves going nowhere..
@codestorywithMIKАй бұрын
Indeed 🙏
@varunpalsingh3822Ай бұрын
Aaj monotonic stack/queue/deque ki need samaj ayi, thanks ❤
@gui-codesАй бұрын
legend is here. i solved leetcode-209 as well. thanks to you
@TanmayMankar-26Ай бұрын
Awesome explanation
@thefinalfitАй бұрын
Was waiting. Thanks a lot
@evigamer1136Ай бұрын
Brother your explanation is awesome keep it up bro
@piyush0mandloiАй бұрын
thank you sir . awesome explanation.
@manavrajthakor8175Ай бұрын
This was my approach for this question but failed to handle negative values : class Solution { public: int shortestSubarray(vector& nums, int k) { int len = INT_MAX; int l = 0; int r = 0; int n = nums.size(); int sum = 0; while(r < n) { sum+=nums[r]; while(sum >=k) { sum-=nums[l]; len = min(len,r-l+1); l++; } r++; } if(len==INT_MAX) { return -1; } return len; } };
@sanebrain3083Ай бұрын
i eactly got stuck at the -ve part part the test was exactly the i was stuck 84 -37 32 40 95
@Shubhammi1100Ай бұрын
waiting for this video
@FanIQQuizАй бұрын
Awesome 🙌
@jscoder-r7zАй бұрын
motivation padh ke maza aa gaya
@38shashwatshukla89Ай бұрын
amazing sir
@gauravbanerjee2898Ай бұрын
Thanks a lot bhaiya ❤❤
@HarmanSingh-nw6ixАй бұрын
good afternoon bhaiya ..
@gui-codesАй бұрын
Anyone need more clarity on why first 84 was removed from deque as soon as we saw a dip from 84 to 47. Here is more points to get more clarity. nums = {84, -37, 37, 40, 95} cumSum = {84, 47, 84, 124, 219} Let's say you are index j = 4, where cumSum is 219 >= k Now, you want to shrink the window. If you notice if you shrink and remove index 0 from left side i.e. 84 Then subarray sum from index 1 to index 4 will be = cumSum[j] - cumSum[0] = 219 - 84 = 135 But if you notice, even if you shrink the window further and remoce index 0 and index 1 from the window, you get the same answer= cumSum[j] - cumSum[2] = 219 - 84 = 135 So there was no point of keeping the first 84 because there was a dip from 84 to 47 and we can get sum >= k further also which will be even shorter subarray. Hope this is clear. Thanks to MIK for improving my thinking skills.
@harsh5720Ай бұрын
Can't we keep count of negative no. We encounter in window if there is negative no. That means there is chance that sum would get increased hence we can shift the window towards left ..
@rnehacodesАй бұрын
Hi Mazhar. Thanks for the video. @codestorywithMIK Just a *small suggestion/request* to add a unique hashtag or keyword to your video title. When stuck with any leetcode question, i often look for your explanation video but due to long channel name it is slightly cumbersome to find the video quickly. As of now, i personally use your git repo to find code snippets and related explanation videos. But if possible, you can include a simple and quick hashtag to your video or any content in general so that we can find your videos quickly. This might help in expanding the reach of channel too as more and more viewers will do organic searches for your hashtag. Rest, keep doing the great work! God bless you!
@codestorywithMIKАй бұрын
Hi there, I appreciate your feedback. Thank you so much. Let me try to add #MIK from now onwards. That might help ❤️🙏
@sumit_verma77Ай бұрын
[80 -30 50] k = 100 so how we can remove 80? it needs to be added in subarray then only we will be able to make 100? I didn't get that part
@codestorywithMIKАй бұрын
As soon as j reaches 50, the cumulativeSum[j] will become = 100 And if you notice I have put a check that if cumulativeSum[j] >= k result = min(result, j+1) So result becomes = 3 So we won’t miss that case also where we reach sum >= 100 here in this example That was a good example. Thanks for this Qn ❤️🙏
@ShardulPrabhuАй бұрын
I had same question but got ans thanks
@s09021994Ай бұрын
Hey sorry but how will [10,80,-30,50] work with k=100?
@alokkumar4419Ай бұрын
@@s09021994 The deque will have values 0, 2, 3 as index because cumulative sum for 0, 2 and 3 index is 10, 60, and 110 respectively.. So the while loop used for reducing the size will manage this scenario.
@sajalchoukseyАй бұрын
You explain great, But plz try to upload solutions of Leetcode contest at least of only EASY level
@codestorywithMIKАй бұрын
Yes definitely. Actually i always travel during weekends to take break. I will try to upload them as well. Thank you for your kind words ❤️🙏
@jeehub041Ай бұрын
Ist view as always ❤❤
@dayashankarlakhotia4943Ай бұрын
First 🎉❤
@Sumit-wy4zpАй бұрын
sir please "sweep line " algorithm pe video banaiye..🥺🥺🥺🥺
@rickdutta942Ай бұрын
Solved the medium after watching your video but stuck on this problem 😔😔
@d_Editzz4003Ай бұрын
can anyone explain how would i know whether to apply sliding window or not according to the questions
@harjotanand834Ай бұрын
So sir ...You mean to say that suppose we wish to move ith pointer ...its possible that cumSum is larger or greater and we cannot obtain sum >= k and also if we get there maybe some smaller cumSum ahead of i and if we subtract it with that lesser cumSum we may get sum >= k ..SO we keep track of previous elements in increasing order so that we have min or less element to check with ( which gives higher chances of getting sum >= k ) and then for larger and again larger so as to see if we can shrink ... Am I Correct ?? IF NOT please correct sir 🙏🏻🙏🏻
@gui-codesАй бұрын
Are aise samjho. nums = {84, -37, 37, 40, 95} cumSum = {84, 47, 84, 124, 219} Let's say you are index j = 4, where cumSum is 219 >= k Now, you want to shrink the window. If you notice if you shrink and remove index 0 from left side i.e. 84 Then subarray sum from index 1 to index 4 will be = cumSum[j] - cumSum[0] = 219 - 84 = 135 But if you notice, even if you shrink the window further and remoce index 0 and index 1 from the window, you get the same answer= cumSum[j] - cumSum[2] = 219 - 84 = 135 So there was no point of keeping the first 84 because there was a dip from 84 to 47 and we can get sum >= k further also which will be even shorter subarray. Hope this is clear
@harjotanand834Ай бұрын
@gui-codes yaa bro got that thanks
@gamersgame43Ай бұрын
I just exactly stuck on this problem test case 51 / 98 testcases passed, which was shown in 2:57, just tried 1hr to figure out how can I use slidiing window, then only came here
@yatheshtpoonia9225Ай бұрын
i was able to do the question you asked in the video but even after that aaj wala solution chamka nahi
@anjumaurya5603Ай бұрын
Can we solved it using brute force?
@pradeepranjan8226Ай бұрын
yes, but it will only give TLE. But you must start with Brute force (82/98 testcase passed) Java Brute force: class Solution { public int shortestSubarray(int[] nums, int k) { int len = 10000000; //any max number //check each subarray for(int i = 0; i < nums.length; i++){ for(int j = i; j < nums.length; j++){ int sum = 0; //window sum for(int s = i; s = k){ len = Math.min(len, j - i + 1); } } } return len == 10000000 ? -1 : len; } }
@RishabhChatterjee-fg2gzАй бұрын
Bhaiya mene bhi yehi example pe atak gya tha
@hellsterkun8764Ай бұрын
Can we solve this question by not using dequeue?
@3mbgaming444Ай бұрын
First comment
@StudentjatinJatinАй бұрын
(1574. Shortest Subarray to be Removed to Make Array Sorted ) bhaiya please isa monotonic sa bna do ma 3 din sa try kar ra 🙂🙂
@DarkDragon-bz6qpАй бұрын
Why using Dequeue cant we use Stack here?As we can get increasing Sequence using Stack..What is the special advantage of using Double ended Queue ?it only allows insertion and deletion from both start and end
@gui-codesАй бұрын
The only benefit is that you can shrink the window from left side which is the requirement of this problem. You can pop from left side and push from right side.
@DarkDragon-bz6qpАй бұрын
@gui-codes Yeah got it thanks..Saw his previous video on power subarrays part 1
@ex.comfy_errorАй бұрын
sir black screen pe code kia kr ye pls ! anyways ,thanks for valuable effort
@codestorywithMIKАй бұрын
Sure definitely. ❤️ Next video in black screen
@TanmayMankar-26Ай бұрын
-28 81 -20 28 -29 plz explain me this testcase
@dayashankarlakhotia4943Ай бұрын
my solution without using dq. public int shortestSubarray(int[]nums,int k){ int n=nums.length; long[]prefix =new long[n+1]; for(int i=0;i
@mananatal5644Ай бұрын
bhaiya please use dark theme in vs code😅😅
@codestorywithMIKАй бұрын
Yes definitely. Actually i was travelling back home and hence forgot to switch to dark mode in rush. ❤️🙏
@mananatal5644Ай бұрын
@@codestorywithMIKthanks 😀 also please make video on infix to postfix and prefix conversion using stack
@dibbodas4116Ай бұрын
bhaiya why 84 is irrelevant i didnt understand that part
@gui-codesАй бұрын
Are aise samjho. nums = {84, -37, 37, 40, 95} cumSum = {84, 47, 84, 124, 219} Let's say you are index j = 4, where cumSum is 219 >= k Now, you want to shrink the window. If you notice if you shrink and remove index 0 from left side i.e. 84 Then subarray sum from index 1 to index 4 will be = cumSum[j] - cumSum[0] = 219 - 84 = 135 But if you notice, even if you shrink the window further and remoce index 0 and index 1 from the window, you get the same answer= cumSum[j] - cumSum[2] = 219 - 84 = 135 So there was no point of keeping the first 84 because there was a dip from 84 to 47 and we can get sum >= k further also which will be even shorter subarray. Hope this is clear
@xboy2374Ай бұрын
sir leetcode ko dark mode kara karo plz
@codestorywithMIKАй бұрын
Yes actually i was travelling back to home. In rush i missed to make dark theme. Apologies for inconvenience. Will take care from next video ❤️🙏
@jimmyaghera1897Ай бұрын
why use deque why not just queue ?
@codestorywithMIKАй бұрын
In que you won’t be able to pop from behind to maintain monotonic nature. Notice that in order to make it increasingly monotonic we will have to pop from behind. Also to shrink the window, we need to pop from front also. So deque provides both functionalites
@akashkumarmaurya2319Ай бұрын
majo me bhai ?
@AdarshShukla-nl1ijАй бұрын
bhai java me code chahiye tha
@codestorywithMIKАй бұрын
Please check the github link in the description . It has java code too ❤️
@abhaysharmafitnessАй бұрын
late ho gaya thoda
@codestorywithMIKАй бұрын
Apologies for inconvenience. I am exploring Hyderabad this long weekend and hence the delay. ❤️🙏
@mehranahmed3612Ай бұрын
@@codestorywithMIK Dont even be sorry about it. I started solving daily challenges because of you posting the solutions later.