Longest Substring Without Repeating Characters (Leetcode 3) - Medium (Hindi)

✅ Useful Links
𝐈𝐧𝐬𝐭𝐚𝐠𝐫𝐚𝐦 - / codingwithprakash
𝐖𝐡𝐚𝐭𝐬𝐀𝐩𝐩𝐂𝐡𝐚𝐧𝐧𝐞𝐥 - whatsapp.com/channel/0029VaAC...
𝐋𝐢𝐧𝐤𝐞𝐝𝐢𝐧 - / prakash-shukla
✅ 𝐋𝐞𝐞𝐭𝐜𝐨𝐝𝐞 𝐏𝐥𝐚𝐲𝐥𝐢𝐬𝐭 - • Leetcode solutions
Longest Substring Without Repeating Characters (Leetcode 3)
leetcode.com/problems/longest...
Music Credit
Track: Julius Dreisig & Zeus X Crona - Invisible [NCS Release]
Music provided by NoCopyrightSounds.
Watch: • Julius Dreisig & Zeus ...
Free Download / Stream: ncs.io/InvisibleYO

Пікірлер: 57

  • @CodingWithPrakash_
    @CodingWithPrakash_3 ай бұрын

    ✅ Useful Links 𝐈𝐧𝐬𝐭𝐚𝐠𝐫𝐚𝐦 - instagram.com/codingwithprakash/ 𝐖𝐡𝐚𝐭𝐬𝐀𝐩𝐩𝐂𝐡𝐚𝐧𝐧𝐞𝐥 - whatsapp.com/channel/0029VaACtTa4tRrpDCQc5f44 𝐋𝐢𝐧𝐤𝐞𝐝𝐢𝐧 - www.linkedin.com/in/prakash-shukla/

  • @magic.pencil2.0
    @magic.pencil2.02 жыл бұрын

    Greate Explanation in one pass only I understood all thanks bro!!!!

  • @market_advice266
    @market_advice2663 жыл бұрын

    Very good video. Please continue the great work..

  • @satyanarayanmohanty3415
    @satyanarayanmohanty34153 жыл бұрын

    Brilliant explanation as always.

  • @user-bc1mp6rh1t
    @user-bc1mp6rh1t10 ай бұрын

    Thanks bro. It is my second day of searching solution of this problem but not able to understand it. you made me understand the logic and thank you for not making your code look fancy*...

  • @CodingWithPrakash_

    @CodingWithPrakash_

    9 ай бұрын

    Glad it helped

  • @HomesickCoder
    @HomesickCoder2 жыл бұрын

    brilliant explanation bhaiya

  • @shreyasmante8914
    @shreyasmante89144 ай бұрын

    excellent !!! 5 min mei samj gya

  • @CodingWithPrakash_

    @CodingWithPrakash_

    4 ай бұрын

    great

  • @AmiMish0909
    @AmiMish09093 жыл бұрын

    Great content

  • @sagarzambre7205
    @sagarzambre7205 Жыл бұрын

    Well explained..🙌

  • @abhinaybelde8233
    @abhinaybelde82332 жыл бұрын

    best video so far!!

  • @mr.mohitrathore9263
    @mr.mohitrathore92632 жыл бұрын

    Really help full sir

  • @krishnar9932
    @krishnar9932 Жыл бұрын

    Nice explanations

  • @CDACCCEE
    @CDACCCEE3 ай бұрын

    good way to implement the idea, do 1 favour also please explain with dry run also,i was stuck in the last step when Left is at a and we have 2 b remaining

  • @akhandpratapsingh2814
    @akhandpratapsingh28142 жыл бұрын

    Good work 👍

  • @GhostRider....
    @GhostRider.... Жыл бұрын

    Nice Explanation bhai

  • @umeshnaik844
    @umeshnaik844 Жыл бұрын

    Best explanation

  • @srinivaskonduri7496
    @srinivaskonduri74963 жыл бұрын

    Very good video. Please continue the great work sir...

  • @CodingWithPrakash_

    @CodingWithPrakash_

    3 жыл бұрын

    Thanks srinivas

  • @davidwarner325
    @davidwarner325 Жыл бұрын

    great explanation But I coded it it without using second while loop ---------------------------------------- class Solution { public int lengthOfLongestSubstring(String st) { Set s = new HashSet(); int count = 0; int max = 0; int left = 0 ,right=0; while(rightmax){ max=count; } } return max; } }

  • @subirkumar6786

    @subirkumar6786

    Жыл бұрын

    but i think now runtime increases

  • @batataphotography1479
    @batataphotography147910 ай бұрын

    class Solution { public int lengthOfLongestSubstring(String s) { int i=0,j=0,max=0; HashSet seen= new HashSet(); //sliding window-first stays,second expands //j is for all distinct charecters while(j

  • @akshayaswain8402

    @akshayaswain8402

    2 ай бұрын

    Very very brilliant answer

  • @dhavalpatel4603
    @dhavalpatel46032 ай бұрын

    What's substring of dvdf?

  • @kbarot3886
    @kbarot3886 Жыл бұрын

    Please do a video for Longest Repeating Character Replacement also

  • @tilakrajchoubey5534
    @tilakrajchoubey55342 жыл бұрын

    Do we really need nested while loop?

  • @MOD_Podcast_
    @MOD_Podcast_Ай бұрын

    class Solution { public int lengthOfLongestSubstring(String s) { int left = 0 , right = 0; int maxLen = 0; HashSet set =new HashSet(); while(righttrue maxLen = Math.max(maxLen , right-left+1); right++; }else{ while(set.contains(c)){ set.remove(s.charAt(left)); left++; } } } return maxLen; } }

  • @RavinderSingh-nh6th
    @RavinderSingh-nh6th Жыл бұрын

    very nice explanation. Thanks

  • @CodingWithPrakash_

    @CodingWithPrakash_

    8 ай бұрын

    You are welcome

  • @ShubhamSingh-jx1ip
    @ShubhamSingh-jx1ip5 ай бұрын

    Your explanation is tooo good sir thank you 😊

  • @CodingWithPrakash_

    @CodingWithPrakash_

    3 ай бұрын

    Most welcome

  • @NinjaCoders
    @NinjaCoders10 ай бұрын

    Awesome video, please keep it up.

  • @CodingWithPrakash_

    @CodingWithPrakash_

    10 ай бұрын

    Thanks, will do!

  • @akshaygoyal4118
    @akshaygoyal41184 ай бұрын

    function getLongestSubstring(str){ let arr = str.split(""); let maxRes='' let start =0; let hashMap = new Map() for(let end =0; end if(hashMap.has(arr[end]) && hashMap.get(arr[end]) >= start){ start = hashMap.get(arr[end]) +1 } hashMap.set(arr[end], end); let mystring = str.substring(start, end+1); if(maxRes.length maxRes = mystring } } return maxRes }

  • @techie_bhuvi
    @techie_bhuvi2 жыл бұрын

    Although explanation is good but there is one correction brute force approach time complexity would be 0(n3)

  • @CodingWithPrakash_

    @CodingWithPrakash_

    2 жыл бұрын

    I guess yes , if he consider substring function complexity

  • @rohandebnath3251
    @rohandebnath325110 ай бұрын

    Hey class Solution { public int lengthOfLongestSubstring(String s) { Set st=new HashSet(); int left=0; int right=0; int max=0; while(right

  • @rishabhrathore8979
    @rishabhrathore89792 жыл бұрын

    Check time complexity?

  • @Ajaykumar-hy2wm
    @Ajaykumar-hy2wm6 ай бұрын

    Bro please upload your upcoming videos in English

  • @PiyushKumar-wh8oh
    @PiyushKumar-wh8oh3 жыл бұрын

    1st View 1st Comment 🎈

  • @CodingWithPrakash_

    @CodingWithPrakash_

    3 жыл бұрын

    🙂 Thanks piyush

  • @18ajai
    @18ajai6 ай бұрын

    you are using nested while loop. How is time complexity o(n) here. it should be O(n*n)

  • @saurabhshiradkar
    @saurabhshiradkar6 ай бұрын

    else { while (seen.contains(c)) { seen.remove(s.charAt(left)); left++; } } in the else part we can use inbuilt contains method of Set Following is the complete code public int lengthOfLongestSubstring(String s) { int left = 0; int right = 0; Set seen = new HashSet(); int max = 0; while (right char c = s.charAt(right); if (seen.add(c)) { max = Math.max((right - left) + 1, max); right++; } else { while (seen.contains(c)) { seen.remove(s.charAt(left)); left++; } } } return max; }

  • @harshalbhagat7669
    @harshalbhagat7669 Жыл бұрын

    Please anyone can explain this??? Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3. Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.

  • @user-hf5bo1mp1c

    @user-hf5bo1mp1c

    11 ай бұрын

    because we have to find substring not subsequence. substrings are continuous while subsequence may not

  • @moinakram4610
    @moinakram46102 жыл бұрын

    Hello I need help here YOur return the length here , but if we want the string how should we take

  • @CodingWithPrakash_

    @CodingWithPrakash_

    2 жыл бұрын

    Join discussion grp

  • @world4376

    @world4376

    2 жыл бұрын

    return the HashSet object but again the function return type should change to HashSet from int.

  • @nmaajidkhan
    @nmaajidkhan Жыл бұрын

    workable c++ easy solution: class Solution { public: int lengthOfLongestSubstring(string s) { unordered_set Set; int left=0, right=0, maxlen = 0; while(right auto it = Set.find(s[right]); if(it == Set.end()){ if(right-left+1 > maxlen){ maxlen = right-left+1; } Set.insert(s[right]); right++; } else{ Set.erase(s[left]); left++; } } return maxlen; } };

  • @manavneekhra4901
    @manavneekhra49012 жыл бұрын

    time complexity O(n) nahi ho sakti aise

  • @praveentakpuriya5431
    @praveentakpuriya54313 жыл бұрын

    isko stack se bhi kr sakte hai??

  • @CodingWithPrakash_

    @CodingWithPrakash_

    3 жыл бұрын

    I think sliding window is the best solution because we are searching substring and we store count in array But try with stack if you can think of solution with it and send it to me

  • @alpha3491
    @alpha34912 жыл бұрын

    If possible use cpp, most of the people prefer that for cp over any other language...btw nicely explained👍

  • @thelazymim9338

    @thelazymim9338

    Жыл бұрын

    Sorry Not Most People. Java syntax is easily readable.

  • @Coding-Just

    @Coding-Just

    Жыл бұрын

    @@thelazymim9338 yes bro cpp is like all are mixture not easily understandable Java syntax are lengthy but anyone can easily understood what can happen

  • @kidoo1567

    @kidoo1567

    9 ай бұрын

    No no Java

Келесі