Sliding Window Leetcode Problem Solved with JavaScript

  Рет қаралды 6,442

James Q Quick

James Q Quick

Күн бұрын

Sliding Window problems have always confused me, but you are likely to see them in a live coding interview on Data Structures and algorithms, so it's worth learning.
In this video, we'll solve Leetcode problem number 209, Minimum Size Subarray Sum, using JavaScript and the Sliding Window algorithm.
Newsletter 🗞 - www.jamesqquick.com/newsletter
*DISCORD*
Join the Learn Build Teach Discord Server 💬 - / discord
*STAY IN TOUCH 👋*
Follow me on Twitter 🐦 - / jamesqquick
Check out the Podcast - compressed.fm/
Courses - jamesqquick.com/courses
*QUESTIONS ABOUT MY SETUP*
Check out my Uses page for my VS Code setup, what recording equipment I use, etc. www.jamesqquick.com/uses

Пікірлер: 20
@surayamelina
@surayamelina 9 ай бұрын
First of all thank you for calling sliding window problems hard!! So nice to have someone validate that for a change, instead of calling them all easy
@JamesQQuick
@JamesQQuick 9 ай бұрын
Oh I think it’s super tricky especially early on. You’re not alone at all!
@kizhissery
@kizhissery 10 ай бұрын
using two pointer left and right . let n = nums.size(); let ans = Number.MAX_SAFE_INTEGER; let l = 0,r = 0,sum = 0; while(r=target){ if(sum>=target){ ans = min(ans,r-l+1); sum -= nums[l++]; } } r++; } if(ans== Number.MAX_SAFE_INTEGER) return 0; return ans;
@eren-qu9wm
@eren-qu9wm Ай бұрын
first i think sliding window algo is hard, then i realised it's very simple. Thank for the tutorial.
@iHidden1
@iHidden1 10 ай бұрын
Thanks James, really good explanation and not rushed through. Would love for this to be a whole series for the 150 problems maybe? Thanks again! Good luck!
@bp-ob8ic
@bp-ob8ic 10 ай бұрын
Loved getting to see this live. Thank you, James, and keep them coming.
@sandhyasrini_
@sandhyasrini_ 10 ай бұрын
Great explanation! Thank you for the video!
@JamesQQuick
@JamesQQuick 10 ай бұрын
So glad you enjoyed it! Have you done sliding window problems before?
@girishpandey9976
@girishpandey9976 6 ай бұрын
Thanks James it really good.....
@Hhammer
@Hhammer 10 ай бұрын
Thanks James this is fun
@JamesQQuick
@JamesQQuick 10 ай бұрын
So glad you enjoyed it. I have fun with these
@cannabisanomaly
@cannabisanomaly 6 ай бұрын
Also, in the leetcode description for the follow up, O(n) is better in time complexity than O(n log(n)), right? Maybe they meant to put O(log(n)) instead?
@karimbouche3563
@karimbouche3563 7 ай бұрын
Yeah bro personally I am interested of the solution of 0(n log(n)) and this kind of challenges,so please continue posting that kind of videos , but essentially it was a wonderful explanation congratulations
@tenthlegionstudios1343
@tenthlegionstudios1343 10 ай бұрын
For me, any time I can get the index's mixed up it becomes especially hard. Things like sliding window or zig zag 2d arrays throw me off. Thanks for the content!
@JamesQQuick
@JamesQQuick 10 ай бұрын
Happy to help!
@vamshireddy8187
@vamshireddy8187 4 ай бұрын
nice
@cannabisanomaly
@cannabisanomaly 6 ай бұрын
0:41 that company is going through some budget cuts and fresh dry erase markers just aren't in the picture
@antonbarbakov9848
@antonbarbakov9848 9 ай бұрын
Nothing clear , but veeery interesting))
@JamesQQuick
@JamesQQuick 9 ай бұрын
Anything I could help explain better?
@r.avinashkumar5372
@r.avinashkumar5372 2 ай бұрын
@JamesQQuick please check this solution. No nested for loops , no nested if condition . Please pin , if correct. I am new to DSA. let nums = [2, 3, 1, 2, 4, 3]; let target = 7; var minSubArrayLen = function (target, nums) { let finalLength = nums.length; let initialIndex = 0; let previousTotal = nums[0]; let i = 0; let sumQueue = [nums[0]]; while (i < nums.length ) { if (previousTotal >= target) { finalLength = Math.min(finalLength, i + 1 - initialIndex); let val = sumQueue.shift(); previousTotal -= val; initialIndex = initialIndex + 1; } else { i = i + 1; sumQueue.push(nums[i]); previousTotal += nums[i]; } } return finalLength; }; console.log(minSubArrayLen(target, nums));
JavaScript Sliding Window Technique - Fixed Size
15:19
The Code Creative
Рет қаралды 14 М.
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 292 М.
这是王子儿子吗
00:27
落魄的王子
Рет қаралды 20 МЛН
EVOLUTION OF ICE CREAM 😱 #shorts
00:11
Savage Vlogs
Рет қаралды 12 МЛН
Sliding Window Technique - Algorithmic Mental Models
36:45
Ryan Schachte
Рет қаралды 337 М.
Sliding Window Technique
6:18
Profound Academy
Рет қаралды 7 М.
Algorithm Sliding Window -  Dynamic Version
20:32
DuoWei Education
Рет қаралды 5 М.
JavaScript Visualized - Event Loop, Web APIs, (Micro)task Queue
12:35
Sliding Window Technique | Google Coding Interview | Maximum Size SubArray Of Size K
16:06
JAVAAID - Coding Interview Preparation
Рет қаралды 64 М.
My Brain after 569 Leetcode Problems
7:50
NeetCode
Рет қаралды 2,5 МЛН
Sliding Window Maximum | Leetcode #239
25:38
Techdose
Рет қаралды 52 М.
这是王子儿子吗
00:27
落魄的王子
Рет қаралды 20 МЛН