Number of Substrings Containing All Three Characters | Leetcode | Medium | Java

Поділитися
Вставка
  • Опубліковано 25 жов 2024

КОМЕНТАРІ • 15

  • @SWETARAWAT-p3s
    @SWETARAWAT-p3s 10 місяців тому +1

    Very structured and to the point video. Love it ❤

  • @rohitchauhan1461
    @rohitchauhan1461 8 місяців тому +1

    Nice Explanation 👍
    keep doing

  • @vinayaksinghal
    @vinayaksinghal 9 місяців тому +1

    One improvement you can make is increasing the volume a bit. Because I am listening to it at full volume and think that it can be increased a bit from your side. Explanation was good.

  • @yatendraupadhyay2180
    @yatendraupadhyay2180 5 місяців тому +2

    Your teaching is very effective Mam.
    Just put some time to discuss intuition, approach and complexity of the code.

  • @Ybash2979
    @Ybash2979 4 місяці тому +1

    best explanation ... most easy ♥

  • @EntertainmentZoneSince1994
    @EntertainmentZoneSince1994 8 місяців тому

    Please discuss Brute force approach & complexity .

  • @NarenRSKumar
    @NarenRSKumar 7 місяців тому +1

    Can you please do your explanation in English. It would help a wider range of audience.

  • @aniksadhukhan8477
    @aniksadhukhan8477 8 місяців тому

    Brilliant explanation

  • @anandpandey918
    @anandpandey918 16 днів тому

    //Bruteforce Approach
    class Solution {
    public int numberOfSubstrings(String str) {
    int count = 0;
    for (int start = 0; start < str.length(); start++) {
    for (int end = start; end < str.length(); end++) {
    if ((end - start + 1) >= 3 && isValidSubstring(str, start, end)) {
    count++;
    }
    }
    }
    return count;
    }
    private boolean isValidSubstring(String str, int start, int end) {
    boolean foundA = false, foundB = false, foundC = false;
    for (int i = start; i 0 && frequency[1] > 0 && frequency[2] > 0) {
    // count all substrings that start from 'start' and end at any index from 'end' to the end of the string.
    count += str.length() - end;
    /*
    * Ex: aaabcaccaa
    * when start=0 and end=4
    *
    * we have following valid subtrings:
    * "aaabc", "aaabca", "aaabcac", "aaabcacc", "aaabcacca", "aaabcaccaa". i.e str.length() - end
    *
    * similarly when start =1 and end =4
    *
    * we have following valid subtrings:
    * "aabc", "aabca", "aabcac", "aabcacc", "aabcacca", "aabcaccaa". i.e str.length() - end
    */
    // Shrink the window from the left
    frequency[str.charAt(start) - 'a']--;
    start++;
    }
    }
    return count;
    }
    }

  • @Digvijaysingh-g2p
    @Digvijaysingh-g2p 9 місяців тому

    ur linkedin pls

  • @ashutoshpandey9064
    @ashutoshpandey9064 10 місяців тому

    First comment😂

    • @aakashpatel1250
      @aakashpatel1250 10 місяців тому +2

      Explanation kaisa tha uske bare me likh...😅

    • @bhatiasatwik
      @bhatiasatwik 9 місяців тому

      Good ​@@aakashpatel1250