Longest Substring with at most K Unique Characters | Hashmap Interview Questions Playlist

Поделиться
HTML-код
  • Опубликовано: 22 авг 2024

Комментарии • 26

  • @umangkumar2005
    @umangkumar2005 Год назад +1

    c++ correct code can be submiited on coding ninja
    #include
    int kDistinctChars(int k, string &s)
    {

    int j=-1;
    int ans=-1;
    mapm;

    for(int i=0;i

  • @angadrajsingh4311
    @angadrajsingh4311 3 года назад +1

    real cse engineering kaha hai -> pepcoding ke channel pe. Love u team pepcoding

  • @SingerChakra
    @SingerChakra Год назад

    acbbacc - size 7 hai tumhara 6 kyun AA raha hai

  • @rohitshinde8478
    @rohitshinde8478 3 года назад

    Thank you sir very much

    • @Pepcoding
      @Pepcoding  3 года назад

      Thankyou beta!
      I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
      If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @sandeepraja1470
    @sandeepraja1470 3 года назад +5

    In the "release" while loop, whether the length update is really required? because while releasing the length won't be longer than the length when acquired, correct?

    • @Pepcoding
      @Pepcoding  3 года назад +1

      Beta, I regret to inform you that, I won't be able to answer/solve the personal doubts of each and every student over here. For clearing your doubts, you can join our community on telegram - t.me/pepcoding.

    • @rahulranjan7567
      @rahulranjan7567 3 года назад

      Yes. No need to see in the release. It will add the overhead. The relase will always be shorter window then acquire

    • @pranavsharma7479
      @pranavsharma7479 2 года назад

      @@rahulranjan7567 sahi kha sabhi ques mein mein release wala window chota aa rha hai, tu acquire wale mein hi ans collect krna bettr hai

  • @SumitSingh-ui4do
    @SumitSingh-ui4do 2 года назад

    Wow sir...❤️❤️

    • @Pepcoding
      @Pepcoding  2 года назад

      Glad it helped!
      Keep learning.
      And for better experience and well organised content visit nados.pepcoding.com

  • @kaustubhshrivastava3169
    @kaustubhshrivastava3169 3 года назад +2

    sir aap solution ka sath ma brute force + optimized + complexity bhi plz bata dejiya
    it helps to think the approach

    • @Pepcoding
      @Pepcoding  3 года назад +2

      ok ji

    • @LegitGamer2345
      @LegitGamer2345 3 года назад +1

      @@Pepcoding yessir , atleast try for one brute force solution and then aap humko optimised solution bata do warna interviewer pakad lega ki hamne already problem kiya hai

  • @mickyman753
    @mickyman753 2 года назад +1

    just one line changes between exactly k and atlmost k
    if(hm.size()==k+1)
    break;
    else;
    maxlen=Math.max(maxlen,i-j);

  • @DurgaShiva7574
    @DurgaShiva7574 2 года назад

    you are the GOD of teaching .. and BEST in programming,,,, thankyou for such an amazing content.

    • @Pepcoding
      @Pepcoding  2 года назад +1

      Keep learning.
      And for better experience and well organised content visit nados.pepcoding.com

  • @jeevangautam4724
    @jeevangautam4724 2 года назад

    sir pls make a video on Leetcode 395-> Longest Substring with At Least K Repeating Characters 🙏🙏🙏

  • @loserfruit9663
    @loserfruit9663 3 года назад +1

    Kya koi mereko aisa test case bta sakta ha jisme longest atmost k character ki substring exactly k character ke longest substring se different ho?

    • @dakshchhabra5975
      @dakshchhabra5975 3 года назад +1

      aaaa
      k=2
      Answer for atmost 2 is 4
      Ans for exactly 2 is 0

    • @mridulgupta4185
      @mridulgupta4185 3 года назад +1

      @@dakshchhabra5975 nice🙌

  • @adityajasood4891
    @adityajasood4891 Год назад

    sir, plz help what is wrong in my code.
    import java.util.*;
    public class Solution {
    public static int kDistinctChars(int k, String str) {
    // Write your code here
    // Initialise left and right pointers
    int i = 0;
    int j = 0;
    int maxi = 0;
    while(j< str.length()) {
    Map map = new HashMap();

    if(map.get(str.charAt(j)) == null) {
    map.put(str.charAt(j),1);
    } else {
    map.put(str.charAt(j), map.get(str.charAt(j))+1);
    }
    if(map.size() k) {
    while(map.size() > k) {

    map.put(str.charAt(i), map.get(str.charAt(i))-1);
    if(map.get(str.charAt(i)) == 0) {
    map.remove(str.charAt(i));
    }
    i++;
    }
    j++;
    }
    }
    return maxi;
    }
    }

  • @syedhabeebuddin7637
    @syedhabeebuddin7637 3 года назад

    this was Awesome ! but sir i have a small confusion about the in hand salaries of fang companies..... PLZ REPLY.... How much amount can we expect to be transfered into our bank account every month ?.....excluding stocks, taxes and all from the ctc (specifically for Amazon and Microsoft) i know their BASE SALARY will be around 12-13lpa but how much inhand ? PLZ REPLY....waiting for reply sir....😊