Sliding Window Technique | Google Coding Interview | Maximum Size SubArray Of Size K

  Рет қаралды 64,882

JAVAAID - Coding Interview Preparation

JAVAAID - Coding Interview Preparation

4 жыл бұрын

Sliding Window Technique: In this video, I have explained sliding window technique which is the optimal way to solve maximum size subarray of size K coding interview problem.
There are a lot of coding interview problems which can be solved by using this technique in an optimized way.
🔴 DONT CLICK THIS: bit.ly/2G4cEuc
👍 Like us on Facebook: / javaaid
💎Share this video with your friend: • Sliding Window Techniq...
💡 Source code:gist.github.com/kanahaiya/bdd...
✚ Join our community ►
👉 Coding interview preparation group: / codingip
👉 Telegram link for algorithmic tutorial: t.me/javaaid
👉 Telegram link for hackerrank solutions: t.me/hackerranksolutions
✅ Recommended playlists ►
👉 Dynamic Programming Tutorial For Beginner: • Dynamic Programming Te...
👉 New To JAVAAID ? Watch These Videos: • Prefix Sum Algorithm |...
👉 Algorithms Fundamental: • Algorithms Fundamental
👉 Coding Interview Questions: • Coding Interview Quest...
👉 All hackerrank solutions: • How To Master In Data ...
📖 TOP 10 LEARNING RESOURCES
1) Cracking the Coding Interview :amzn.to/30HFJCE
2) Algorithms Hardcover :amzn.to/30Hjdd9
3) The Algorithm Design Manual :amzn.to/2AEtEDL
4) Data Structures & Algorithms in Java :amzn.to/2AG82ag
5) Data Structures and Algorithms Made Easy :amzn.to/2M8UvNK
6) Grokking Algorithms :amzn.to/2LKu8yD
7) Dynamic Programming for Coding Interviews :amzn.to/2AC7BO9
8) Introduction to Algorithms :amzn.to/2oSJAzq
9) Elements of Programming Interviews in Java :amzn.to/30MBjKO
10) Programming Interviews Exposed :amzn.to/2V8mFfO
👋 Let’s Connect ►
Git Hub: github.com/kanahaiya
Twitter: / kanahaiyagupta
Linked in: / kanahaiya-gupta
Facebook: / coolkanahaiya
Instagram: / javaaid.algorithms
#JAVAAID #slidingwindowtechnique #leetcode #javaAidTutorials #programming #dataStructures #algorithms #coding #competitiveprogramming #google #java #codinginterview #problemsolving #kanahaiyaGupta #google #facebook #amazon #oracle #linkedin
DISCLAIMER: These above-mentioned resources have affiliate links, which means if you buy one of the products from my links, I might receive a small commission without having an extra cost to you. This helps support the channel and allows us to continue to add more tutorial. Thank you for your support!
NOTE: All above-shared learning resources are best of my knowledge as I have personally read all except one Introduction to Algorithms.

Пікірлер: 173
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
*corrections* *Initialize the msum to Integer.MIN_VALUE because all the wsum may be negative and in that case the msum will never be updated by the wsum.* and in second method, *maxSum = Math.max(maxSum, windowSum); // added as a part of correction* public static int getMaxSumSubArrayOfSizeKM2(int[] A, int k) { int windowSum = 0, maxSum = Integer.MIN_VALUE; for (int i = 0; i < k; i++) { windowSum += A[i]; } *maxSum = Math.max(maxSum, windowSum); // added as a part of correction* for (int windowEndIndex = k; windowEndIndex < A.length; windowEndIndex++) { windowSum += A[windowEndIndex] - A[windowEndIndex - k]; maxSum = Math.max(maxSum, windowSum); } return maxSum; }
@himanshujain7014
@himanshujain7014 4 жыл бұрын
Hello sir I am yr follower on Hacker rank ,I am also 6 star in Hacker rank but what to do next?
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
choose another platform like codechef or codeforces and get the 6 star their also.
@arunkumarvenkatesan1470
@arunkumarvenkatesan1470 4 жыл бұрын
Hi, Actually your code not working for Following input For example int [] a={3,2,6,-1,4,5,-1,2} Exact output will be 11. But your code gives 9. Please change your code little bit following type modle Inside for loop Maxsum=math.max(winsum,maxsum); Winsum+=A[end]-A[end-k]; Now its works fine Its will gives 11
@himanshujain7014
@himanshujain7014 4 жыл бұрын
@@JavaAidTutorials yes I am doing at code chef there I am 2 star but I want to do job? Do you have any idea sir?
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Did not get your query ? what idea you are talking about?
@robertsedgewick1266
@robertsedgewick1266 4 жыл бұрын
Explaining tough problems with a dry explanation is easy and commonplace. Your work is brilliant because it makes tough problems seem easy to solve!
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks a lot for this feedback. If you find this channel helpful , please do share among your friends.
@aeon7748
@aeon7748 Жыл бұрын
I don't have an interview but was looking for a solution to a sliding window problem for my program, I thank you for your unique style in teaching It's very clear and easy, thank you.
@sureshgarine
@sureshgarine 2 жыл бұрын
I can see your efforts in the present it in a more colorful and meaningful way with a nice presentation and communication. awesome job. I see many youtube, but never see one as you presented it very aesthetically. keep up the good work. your subscribers will increase sooner or later,
@pedestrian9287
@pedestrian9287 4 жыл бұрын
Excellent video and terrific explanation! Best video on this topic on KZbin!
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks for such a lovely feedback.
@amitaher31
@amitaher31 4 жыл бұрын
Very cool man, keep up the good work.. thanks for adding the correction.. I know many interviewers today look for these edge cases!
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks for the feedback 😊, If you find the tutorial helpful, please do share with your friends also.
@anushree3744
@anushree3744 4 жыл бұрын
Happily subscribed. Great to see you discussing the patterns. Keep them coming. One request though, please site some problems that can be solved using the pattern. It will be an exercise to the viewer and will complete the learning cycle
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thank you for providing such a nice feedback. Sure will start including the problems also.
@tentx652
@tentx652 2 жыл бұрын
better understanding after watching the video...!! great going man
@law5
@law5 3 ай бұрын
Your explanation on this topic was very clear. Keep it up!
@pzkpfwvii7090
@pzkpfwvii7090 4 жыл бұрын
Thank you for your videos. Respect man! You're Waffentrager E100 in algorithm world!
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks 😊 If you find this channel helpful, please support us by sharing it with your friends....🙏🙏
@vaibhavikhachane6225
@vaibhavikhachane6225 2 жыл бұрын
In first for loop you need to write "maxSum =windowSum" because if we are getting the max in our first for loop than we need to return that maxSum;
@saravananj3898
@saravananj3898 3 жыл бұрын
trust me this the best video u can find in youtube in this topic
@benneal8224
@benneal8224 4 жыл бұрын
Awesome explanation! Thanks for putting these up as they are very beneficial.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Glad you like them! If you find it useful, please do share with other too.
@saumyadeepdebnath6412
@saumyadeepdebnath6412 3 жыл бұрын
Very nice explanation bhaiya... Thank you
@apnasid794
@apnasid794 2 жыл бұрын
Good work sir keep it.👍
@subhamjain707
@subhamjain707 4 жыл бұрын
Great explanation..Just continue making such conceptual videos.Its going to help a lot.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Sure @Subham. If you find our channel helpful, please do share with your friends too.
@vinothiniseenivasan1502
@vinothiniseenivasan1502 Жыл бұрын
thanks for crystal clear explanation.....
@elgatito00
@elgatito00 3 жыл бұрын
Great explanation 🤝
@xotic37
@xotic37 2 жыл бұрын
Great sir great great great I will Sher my friend your chanel link thank so mush sir really Good
@kesharwani.prashant
@kesharwani.prashant 3 жыл бұрын
You are an amazing teacher!!!
@aravinddesikamani
@aravinddesikamani 4 жыл бұрын
I am sure that your subscribers count will grow with exponential complexity.. Keep the great work up😇
@himanshujain7014
@himanshujain7014 4 жыл бұрын
I am completely agree with u
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
thank you @Aravind I am also hoping the same. Let's C.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
@@himanshujain7014 thanks
@Spider-Man_67
@Spider-Man_67 Жыл бұрын
Man...your explanations are epic
@vigneshhendrix4447
@vigneshhendrix4447 4 жыл бұрын
I've been Stuck in this particular problem . Have watched many videos. But I can't understand their way of explanation . But you just Nailed it. Keep doing videos in some special questions asked by huge product based companies please.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Glad to hear that
@dipakvyawahare
@dipakvyawahare 3 жыл бұрын
Best explanation!! thanks
@ashutoshsingh5568
@ashutoshsingh5568 3 жыл бұрын
Awesome explanation bro. Keep teaching DSA. God bless you.
@samrey8134
@samrey8134 3 жыл бұрын
After 2 weeks at this, I family got it. You are the best. Thank you so much
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
Great to hear!
@chrispure7461
@chrispure7461 Жыл бұрын
I love you man..great explanation.
@anupamachanamolu2678
@anupamachanamolu2678 Жыл бұрын
Great explanation.
@abhinavvgoyall
@abhinavvgoyall Жыл бұрын
Best explanation!
@TridibSamanta
@TridibSamanta 4 жыл бұрын
Awesome explanation ! Keep up the good work :)
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
thanks a lot for your feedback .🙂
@peddibharath7016
@peddibharath7016 9 ай бұрын
Great explanation
@manojprabhu5641
@manojprabhu5641 2 жыл бұрын
very usefull :) tq bro.
@mongaslanguagetechnologies58
@mongaslanguagetechnologies58 4 жыл бұрын
Thanks. This is a very common interview question.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
yes, it is asked in many coding interview.
@prasaad44
@prasaad44 3 жыл бұрын
Superb bro..... pls continue more on this....
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
Thank you, We will
@madhutalaari
@madhutalaari 3 жыл бұрын
your videos and explanations are making me feel that Datastructures and algorithms are actually not tough.. I understood this problem so easily ( may be this is an easy one :P).. Thankyou!!
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
You can do it!
@arunkumarvenkatesan1470
@arunkumarvenkatesan1470 4 жыл бұрын
Very nice explanation ...I want more this type of videos.i need to learn new ideas..your videos really superb..please share more videos..with explanation
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks for your feedback @arun. I am trying my best to teach you all. Stay tuned, for cool stuff.
@zavier3436
@zavier3436 3 жыл бұрын
Just awesome ❤️
@urunovtimes5816
@urunovtimes5816 3 жыл бұрын
you are one of the my friend, from India. Oh my goodness. You are really clear explained in the wsa
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
Thank you :) If you like our content please share with others too
@vikasmastud7005
@vikasmastud7005 4 жыл бұрын
Very easy to understand and nice visual representation of sliding window techniq
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks vikas for your feedback.
@guess_d2s344
@guess_d2s344 Жыл бұрын
Thank you for explaining this concept in really nice way. Awesome 👍👍
@JavaAidTutorials
@JavaAidTutorials Жыл бұрын
Most welcome 😊
@rajgupta6738
@rajgupta6738 2 жыл бұрын
you are amazing
@beamazing2915
@beamazing2915 Жыл бұрын
GOOD EXPLANATION
@geetusharma3923
@geetusharma3923 4 жыл бұрын
Very nice explanation . Thanks for valuable content ❤️👍 all the best
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thank you so much 🙂
@kanchanjeswani2001
@kanchanjeswani2001 4 жыл бұрын
Very nice video sir.Thank you so much..
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Most welcome
@venpro8705
@venpro8705 4 жыл бұрын
Super bro👍
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
thanks :)
@pradeepjagtap7220
@pradeepjagtap7220 4 жыл бұрын
You are awesome! Thank you very much.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
most welcome..:)
@hellofriend3091
@hellofriend3091 2 жыл бұрын
Thank you sir ❤️
@venpro8705
@venpro8705 3 жыл бұрын
Your explanation is best than any other youtubers Thanks for ur explanation sir. Keep going From chittoor AP
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
So nice of you 😀 If you find it useful, please do share with your friends as well. 🙏
@senthilkumaran5317
@senthilkumaran5317 4 жыл бұрын
Great explanation with visuals . Subscribed
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
thanks for your nice feedback..😊
@UECAshutoshKumar
@UECAshutoshKumar Жыл бұрын
Thank you sir
@frozen_tortus
@frozen_tortus 4 жыл бұрын
Very nicely explained. This looks like dynamic programming.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks 😊
@akrammohammed1167
@akrammohammed1167 4 жыл бұрын
Great explanation thanks for the wonderful video!
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Most welcome 😊
@rohancombay2689
@rohancombay2689 Жыл бұрын
Damn Good man
@amarchoubey5615
@amarchoubey5615 3 жыл бұрын
Super
@iezioaudi22
@iezioaudi22 5 ай бұрын
Thanks!!!!!!
@nandakumarr9288
@nandakumarr9288 4 жыл бұрын
I ve been finding solution fr this problem over 2 weeks and most of the contant related to this code are neither failed nor not explained correctly but this video is top notch and nailed perfectly.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks for the awesome 🔥 feedback 😊
@nandakumarr9288
@nandakumarr9288 4 жыл бұрын
@@JavaAidTutorials innor prblem ji i have to find index element of maximum value in this same prblm Like 4 5 4 summa = 13 Index = 4 Give me any idea or upload video related to finding index element of subarrray
@mayurravindra9433
@mayurravindra9433 3 жыл бұрын
very helpful!
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
Glad you think so!
@pritammishra9850
@pritammishra9850 4 жыл бұрын
Amazing explanation
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Glad you think so!
@mahmoudabdelsattar8860
@mahmoudabdelsattar8860 Жыл бұрын
please more around these please cover all (BS, TEES, DP.....) please -> ur way is easy
@Roy-zt7sl
@Roy-zt7sl 4 жыл бұрын
Excellent presentation & explanation
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Many thanks!
@shivajunna
@shivajunna 4 жыл бұрын
Nice explanation !!
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thank you :) @Siva
@randomlyrandom7002
@randomlyrandom7002 4 жыл бұрын
Great video sir!
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks for watching
@musadhk
@musadhk 3 жыл бұрын
nicely explained
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
Thank you 😃
@architpandita790
@architpandita790 3 жыл бұрын
Nice Approach
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
Thank you..😊
@rajeshkumar-ty8nj
@rajeshkumar-ty8nj 4 жыл бұрын
I have improved my coding skill through this channel.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Glad to hear that.😊 If you find our channel helpful, please support us by sharing it.
@dheerajkushwaha1657
@dheerajkushwaha1657 4 жыл бұрын
Nice explanation
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks @Dheeraj for your feedback.
@vanngaonguyen9348
@vanngaonguyen9348 4 жыл бұрын
great explanation
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Glad you liked it
@start1learn-n171
@start1learn-n171 2 ай бұрын
Tq
@156sparsh7
@156sparsh7 3 жыл бұрын
Thanks
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
Welcome
@prakashurkude4044
@prakashurkude4044 Жыл бұрын
it's easy to search with question number, so please add question number too in video title.
@ishitaanand4283
@ishitaanand4283 4 жыл бұрын
It really helped me a lot
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
thank you. if you find it helpful, please do share with your friends as well.
@ishitaanand4283
@ishitaanand4283 4 жыл бұрын
@@JavaAidTutorials sure Sir
@benmathew534
@benmathew534 4 жыл бұрын
You can also use a deque. just add to the end of the list and remove from the front
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
yes, using dequeue we can solve this problem if size is fixed but it will not work for dynamic size array.
@dhaanumalavan1968
@dhaanumalavan1968 Жыл бұрын
👌👌
@shashwatshukla3289
@shashwatshukla3289 3 жыл бұрын
Sir ,is prefix sum algorithm a good approach here?
@DTWK
@DTWK 2 жыл бұрын
There is a bug in your optimized solution. You are not storing the sum for the initial window in the max sum. So when doing math.max your first value in the array is not included in the computation.
@kinneravijay617
@kinneravijay617 2 жыл бұрын
I think you should assign windows sum to maxsum befor the 2 for loop that's the correct apporch, because I first four is the maxsum them we are getting wrong answer
@vinothkannans1910
@vinothkannans1910 3 жыл бұрын
Awesome explanation 👍. I got clear clarity. Could you please tell me what is the trick and tips to solve any kind of arrays problems.l mean from easy to complex kind of array problems.
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
Will upload soon, till then keep learning keep coding 😊
@vinothkannans1910
@vinothkannans1910 3 жыл бұрын
@@JavaAidTutorials Thanks a lot 😊
@aishwaryaporwal2321
@aishwaryaporwal2321 3 жыл бұрын
Plss sir also make a vedio on Dutch national flag algorithm technique
@navinchainani4721
@navinchainani4721 3 жыл бұрын
Sir instead of windowsum +=A[end]-A[end-k] we can write windowsum+=A[end]-k
@RakeshKumar-en1uq
@RakeshKumar-en1uq 2 жыл бұрын
Please try to put video based more DSA
@jlecampana
@jlecampana 4 жыл бұрын
Hello there! I always thought that LeetCode problem #560 could be solved using this technique, but as it turns out I was wrong. Could you please explain Why the Sliding Window Technique does not work for such a case? Thank you, and Great video BTW
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
I have just reviewed the leetcode problem and found there is a slight difference in both problem statement. they are asking to return "total number of continuous subarrays whose sum is maximum" instead of maximum sum. Here is the leetcode problem statement for your reference. "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k."
@2cool238
@2cool238 2 жыл бұрын
why does prefix sum not work for this problem
@sohampatra1207
@sohampatra1207 4 жыл бұрын
sir can you make video on the largest rectangle&hackerrank solutions on stack game problem
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
I need some time to upload more content. Due to lockdown, i am stuck without my laptop 😞
@nileshmishra3192
@nileshmishra3192 3 жыл бұрын
Let's consider the eg. int[] arr = {2,1,1,-5}; --> our code here will give answer as 2 & now 3 because we are not comparing windowSum found in first loop with the first occurrence of windowSum in the second loop. We have to add: if(maxSum>count) return maxSum; else return count; //copying windowSum value from the first loop in the count PS: I may be wrong, just learning! sorry if I'm :)
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
Hi @Nilesh, please have a look on pinnned comment to get the answer for your query.
@amitghosh2183
@amitghosh2183 2 жыл бұрын
But array is not sorted. Then how can be answer 13 why not(9+7+3+2)=21.
@Mike-mw1fu
@Mike-mw1fu 4 жыл бұрын
Very nice explanation.I love it Let’s say if the array size is equal to k , the max sum should be sum of array elements. It’s just need a little change for your code, Sir. Thanks a lot
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
thank you @study student. As this is the corner case and the expectation was to explain the technique so I avoided all validations and corner cases so that it will be easy to grasp the core logic. but I agree with you, to handle this scenario,you need to put an additional check before the second loop and done.
@ccarnagee7867
@ccarnagee7867 4 жыл бұрын
please suggest some problems for practicing these algorithms...Codeforces.leetcode,hackerrank any platform..The more the better....
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
will recommend leetcode and hackerrank. To know more, what to use follow below answer- www.quora.com/Which-one-is-better-HackerRank-or-LeetCode/answer/Kanahaiya-Gupta-2
@Abhijeetkumar-jr8fq
@Abhijeetkumar-jr8fq 4 жыл бұрын
in sliding window technique code it is leaving the first element of the array int [] a={44,45,1,2,3}; then the sum will be 45+1+2+3=51 but it should be 92 because you are not considering the first iteration addition for 0 to k-1 that is 92 uncompared
@Abhijeetkumar-jr8fq
@Abhijeetkumar-jr8fq 4 жыл бұрын
between both loop put maxSum=windowSum
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
We have done the correction in our code and mentioned the same in a pinned comment, please follow the pinned comment and let us know if still there is any doubt.
@rishurajan8080
@rishurajan8080 4 жыл бұрын
Hello sir,please may ypu provide source code in c++ as well
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Currently source code is provided only in java language but we are planning to provide it in multiple languages which needs some investment. we will add all feature as we grow. so please share our channel with your friends.It will help us to reach our goal sooner. Mean while you can check out comments on the video ,as lot of people paste their solution in multiple language.
@pramitis2645
@pramitis2645 3 жыл бұрын
Hello
@pramitis2645
@pramitis2645 3 жыл бұрын
May I connect you in faceboook Or anywhere else I need help regarding hackerrank questions
@JavaAidTutorials
@JavaAidTutorials 3 жыл бұрын
sure but don't expect from us to solve hackerrank problems for your assignment or coding interview.. 😀
@akhilchowdary3161
@akhilchowdary3161 4 жыл бұрын
hey a small intimation that u are not comparing the first k values with maximum value
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
yes , we have missed it seems, just added as a part of correction in my pinned comment. Thanks for pointing it out..:)
@ztrixx3280
@ztrixx3280 4 жыл бұрын
Arr = [9,6,6,1,2,3,3,5,7,5] K = 3 If maxSum window is the first window(k elements)...then this technique gives a wrong answer It returns 17 instead of 21 To correct it..the Math.Max line should be about the windowSum formula..
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks for pointing this out but i have already mentioned the corrections in my first comment. Have a look and let me know if i missed something.
@swapnilbmkjs7610
@swapnilbmkjs7610 2 жыл бұрын
There is a error in this problem.... Just write maxsum=windowssum after 1 st for loop then it will work currently.... If u don't believe me... Just put 1st elements of array ie 1 after 4th element of array ie 7 (9,-1,-2,7,1,3,-1,2) u will got output as 10.... Thanks me later
@piotrekkrakowiak5060
@piotrekkrakowiak5060 2 жыл бұрын
For God sake add subtitles or slow down when you speak
@shivamshah431
@shivamshah431 4 жыл бұрын
Correction: Initialize the msum to Integer.MIN_VALUE because all the wsum may be negative and in that case the msum will never be updated by the wsum.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
thanks shivam for pointing this out. I have updated my code and mentioned the same in pinned comment. Even it was not necessary but its always good to handle such cases.
@anamikaahmed4887
@anamikaahmed4887 4 жыл бұрын
There are problems with this code. 1) You are not comparing the first iteration (sum) of the sliding window with maxSum. 2) minimum should be set to Integer.MIN_VALUE. The explanation is great but I think you should have mentioned these corrections in the description box.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks for your detailed feedback. we have already added these corrections long back in our pinned comment and git hub code😊.
@vamsibavanari7409
@vamsibavanari7409 4 жыл бұрын
For the input {7,8,1,3,1,4,1,0}, the max should be returned as 16, but because of the below code, it is returning as 12. Because for the first iteration, we are not assigning the max. value; the maxSum should be the first stmt in the below loop. for(int j=k;j
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
this problem has been already addressed and i have pinged my comment on top. please have a look.
@VerzapierZyGaming
@VerzapierZyGaming 4 жыл бұрын
this cannot be a coding interview problem for google, unless they ask you to do it in DP.. this is basically clickbait
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
If you think this problem is easy and Google always ask hard questions, you can visit this link to clear your doubt. Even the Two sum problem also asked in google interview. kzbin.info/www/bejne/jnzYkIZ7eaasodk
@jay-rathod-01
@jay-rathod-01 4 жыл бұрын
Don't click this😂
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
I hope you have not 😜
Two Pointer Algorithm | Two Sum Problem | Solve DS Problems in O(N) Time
19:18
JAVAAID - Coding Interview Preparation
Рет қаралды 112 М.
Sliding Window Technique - Algorithmic Mental Models
36:45
Ryan Schachte
Рет қаралды 337 М.
Why Is He Unhappy…?
00:26
Alan Chikin Chow
Рет қаралды 72 МЛН
Викторина от МАМЫ 🆘 | WICSUR #shorts
00:58
Бискас
Рет қаралды 5 МЛН
Whiteboard Coding Interviews: 6 Steps to Solve Any Problem
15:18
Fullstack Academy
Рет қаралды 364 М.
Sliding Window Maximum | Leetcode
20:16
take U forward
Рет қаралды 248 М.
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 292 М.
JavaScript Sliding Window Technique - Fixed Size
15:19
The Code Creative
Рет қаралды 14 М.
5 Problem Solving Tips for Cracking Coding Interview Questions
19:12