Minimum Positive Sum Subarray | 3 Approaches | Optimal | Leetcode 3364 | codestorywithMIK
Description: ☕ Support codestorywithMIK (No Pressure)
Education here is 100% free and always will be.
If the content helped you and you'd like to support the channel with a coffee:
UPI: imammazhar4@ybl
--------------------------------------------------
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
Hi Everyone, this is 166th video of our Playlist "Greedy Technique : Popular Interview Problems" by codestorywithMIK"
Today we will be solving a very good problem based on Prefix Sum and Binary Search (lower_bound): Minimum Positive Sum Subarray | 3 Approaches | Optimal | Leetcode 3364 | codestorywithMIK
Problem Name : Minimum Positive Sum Subarray | 3 Approaches | Optimal | Leetcode 3364 | codestorywithMIK
Company Tags : will update later
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Sliding%20Window/Leetcode%20Easy/Minimum%20Positive%20Sum%20Subarray.cpp
Leetcode Link : https://leetcode.com/problems/minimum-positive-sum-subarray
My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My Segment Tree Concepts Playlist : https://www.youtube.com/watch?v=k99r1A7krcY&list=PLpIkg8OmuX-K1qUIQToCllUO0UIKXt8dB
My Recursion Concepts Playlist : https://www.youtube.com/watch?v=pfb1Zduesi8&list=PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM
Trie Playlist - https://www.youtube.com/watch?v=DMP2bqW6URA&list=PLpIkg8OmuX-I99uuP2BZOz4mI_lms4gVG
Difference Array Technique: Concepts & Qns : https://www.youtube.com/watch?v=ZHNVmtm08WY&list=PLpIkg8OmuX-Kqkb8DqDe_4-Tiav6ilS_L
My Line Sweep Technique Playlist : https://www.youtube.com/watch?v=-FxkJiCyg5g&list=PLpIkg8OmuX-IOG_-Bv92l-EhuBQX28LOm
Meet In The Middle : Concepts & Qns : https://www.youtube.com/watch?v=NCr27WYjCH4&list=PLDdmvvl73yuo
Binary Lifting : Concepts & Questions : https://www.youtube.com/watch?v=WTtuOj6FXE8&list=PLpIkg8OmuX-IzZj8UNhVsiWKqTdDcHnP1
Top K from Sorted Structures Pattern : Concepts & Questions : https://www.youtube.com/watch?v=TZwPVMyG8-M&list=PLpIkg8OmuX-KFG7Ku_R-DEN5tk1EAy-8o
Small Java Dopamine Videos : https://www.youtube.com/playlist?list=PLpIkg8OmuX-KxhK6iSmDZeisqw3PEOEU5
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Subscribe to my channel : https://www.youtube.com/@codestorywithMIK
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Video Summary :
Approach 1 (Super Brute Force): Try every start, keep adding elements one by one up to length r, and whenever the length is at least l and the sum is positive, update the minimum.
Approach 2 (Improved Brute Force): Use prefix sums so any subarray sum is just one subtraction. You still try every start and every length in [l, r], but each sum costs O(1) instead of being rebuilt.
Approach 3 (Sliding Window + Multiset): Fix the end j and ask which start gives the smallest positive sum. That is the largest prefix value still smaller than prefixSum[j], among starts whose length is in [l, r]. A sorted multiset holds that sliding window of prefix values, so one lower_bound finds the best start quickly. The 0 entry represents subarrays starting at index 0, and it is removed once those become longer than r.
✨ Timelines✨
00:00 Introduction
00:20 Motivation
00:25 Problem Explanation
00:26 Brute Force
00:28 Slight Optimal
00:30 Most Optimal Detailed
00:35 Corner Case
00:49 Coding most optimal
#MIK #mik #Mik
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik Close description
Education here is 100% free and always will be.
If the content helped you and you'd like to support the channel with a coffee:
UPI: imammazhar4@ybl
--------------------------------------------------
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
Hi Everyone, this is 166th video of our Playlist "Greedy Technique : Popular Interview Problems" by codestorywithMIK"
Today we will be solving a very good problem based on Prefix Sum and Binary Search (lower_bound): Minimum Positive Sum Subarray | 3 Approaches | Optimal | Leetcode 3364 | codestorywithMIK
Problem Name : Minimum Positive Sum Subarray | 3 Approaches | Optimal | Leetcode 3364 | codestorywithMIK
Company Tags : will update later
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Sliding%20Window/Leetcode%20Easy/Minimum%20Positive%20Sum%20Subarray.cpp
Leetcode Link : https://leetcode.com/problems/minimum-positive-sum-subarray
My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My Segment Tree Concepts Playlist : https://www.youtube.com/watch?v=k99r1A7krcY&list=PLpIkg8OmuX-K1qUIQToCllUO0UIKXt8dB
My Recursion Concepts Playlist : https://www.youtube.com/watch?v=pfb1Zduesi8&list=PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM
Trie Playlist - https://www.youtube.com/watch?v=DMP2bqW6URA&list=PLpIkg8OmuX-I99uuP2BZOz4mI_lms4gVG
Difference Array Technique: Concepts & Qns : https://www.youtube.com/watch?v=ZHNVmtm08WY&list=PLpIkg8OmuX-Kqkb8DqDe_4-Tiav6ilS_L
My Line Sweep Technique Playlist : https://www.youtube.com/watch?v=-FxkJiCyg5g&list=PLpIkg8OmuX-IOG_-Bv92l-EhuBQX28LOm
Meet In The Middle : Concepts & Qns : https://www.youtube.com/watch?v=NCr27WYjCH4&list=PLDdmvvl73yuo
Binary Lifting : Concepts & Questions : https://www.youtube.com/watch?v=WTtuOj6FXE8&list=PLpIkg8OmuX-IzZj8UNhVsiWKqTdDcHnP1
Top K from Sorted Structures Pattern : Concepts & Questions : https://www.youtube.com/watch?v=TZwPVMyG8-M&list=PLpIkg8OmuX-KFG7Ku_R-DEN5tk1EAy-8o
Small Java Dopamine Videos : https://www.youtube.com/playlist?list=PLpIkg8OmuX-KxhK6iSmDZeisqw3PEOEU5
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Subscribe to my channel : https://www.youtube.com/@codestorywithMIK
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Video Summary :
Approach 1 (Super Brute Force): Try every start, keep adding elements one by one up to length r, and whenever the length is at least l and the sum is positive, update the minimum.
Approach 2 (Improved Brute Force): Use prefix sums so any subarray sum is just one subtraction. You still try every start and every length in [l, r], but each sum costs O(1) instead of being rebuilt.
Approach 3 (Sliding Window + Multiset): Fix the end j and ask which start gives the smallest positive sum. That is the largest prefix value still smaller than prefixSum[j], among starts whose length is in [l, r]. A sorted multiset holds that sliding window of prefix values, so one lower_bound finds the best start quickly. The 0 entry represents subarrays starting at index 0, and it is removed once those become longer than r.
✨ Timelines✨
00:00 Introduction
00:20 Motivation
00:25 Problem Explanation
00:26 Brute Force
00:28 Slight Optimal
00:30 Most Optimal Detailed
00:35 Corner Case
00:49 Coding most optimal
#MIK #mik #Mik
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik Close description




