Check if sentence is Pangram (LeetCode 1832) | Full solution with multiple techniques

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

КОМЕНТАРІ • 32

  • @rajeevmishra5649
    @rajeevmishra5649 8 місяців тому +2

    You explained all test cases and covered the interview case also. Also you explained why space complexity is O(1). Many say space complexity is O(n) but they don't explain why it is so. Thank you sir

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

      Excellent

  • @inspiredomkar1239
    @inspiredomkar1239 Рік тому +9

    import java.util.Arrays;
    import java.util.HashSet;
    class Solution {
    public boolean checkIfPangram(String sentence) {
    char[] charArray = sentence.toCharArray();
    HashSet hashSet = new HashSet();
    for (char c : charArray) {
    hashSet.add(c);
    }
    return hashSet.size() == 26;
    }
    }
    Here's how i coded this solution.

  • @sasidharnaidu4507
    @sasidharnaidu4507 6 місяців тому +2

    You can add one more if statement that if length of str less than 26, return false

  • @arslanmuhammad4190
    @arslanmuhammad4190 11 місяців тому +1

    Love You Respected SIr.

  • @shwetasdhake7986
    @shwetasdhake7986 3 місяці тому

    Your Code: Checks for empty Set during iteration and incorrectly initializes the Set with letters 'a' to 'z'.
    Instead, we can directly adds characters from the sentence to the Set and checks if the Set contains all 26 letters at the end.

  • @prabirmaity4529
    @prabirmaity4529 Рік тому +2

    Also we can push char into set and check if hashset length equal to 26 that's mean all characters found and return true else at the end return false. Is this approach correct ?

    • @nikoo28
      @nikoo28  Рік тому +2

      yes, that approach is also correct. :)

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

    But it is taking time i.e like 7ms like that .. public boolean checkIfPangram(String sentence) {
    for(char i='a';i

  • @tanishkaagarwal6750
    @tanishkaagarwal6750 Рік тому

    Thank you so much sir. Your teaching style is awesome.

  • @hoddybhaba6704
    @hoddybhaba6704 Рік тому +2

    Bro ..please do video on Leetcode #2384 - Largest Palindromic Number . I did got this in the interview..

    • @nikoo28
      @nikoo28  Рік тому +1

      What interview did you get this in?

    • @hoddybhaba6704
      @hoddybhaba6704 Рік тому +1

      @@nikoo28 got that in the Citi bank coding test.

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

    Thank you so much

  • @ayushsharma5516
    @ayushsharma5516 Місяць тому

    bool checkIfPangram(string sentence) {
    unordered_setunique;
    for(char c:sentence){
    unique.insert(c);
    }
    return unique.size()>=26;
    }
    tc=o(n)
    sc=o(n)
    my solution

  • @cremewe6700
    @cremewe6700 6 місяців тому

    00:02 A Pangram is a string containing all English alphabet letters at least once.
    01:36 Identifying Pangram using character iteration
    03:07 Efficiently check if a sentence is a Pangram
    04:48 Iterate through the string and change array values to 1 for each character encountered.
    06:28 Optimizing for edge cases with efficient approach using hash set
    08:06 Removing characters from a hashset leads to time savings
    09:37 Create hash set, iterate through string, check for pangram
    11:16 Be mindful of edge cases and character considerations in problem solving
    Crafted by Merlin AI.

    • @nikoo28
      @nikoo28  6 місяців тому +1

      Is there an AI tool that did this automatically?

    • @praveenraja859
      @praveenraja859 5 місяців тому

      @@nikoo28

  • @Bhavya__Garg
    @Bhavya__Garg Рік тому

    Sir, Please explain " 36. Valid Sudoku " problem from leetcode

    • @nikoo28
      @nikoo28  Рік тому +1

      sure, I will add it to my list of upcoming videos

  • @shivanimishra2448
    @shivanimishra2448 Рік тому

    Got this question in my last OA round

  • @SergekSh
    @SergekSh Рік тому

    Good Job Man!

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

    Its z sir not g

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

    what if the string contains some upper case letters

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

      Just convert the character x to lower

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

      always check the problem constraints. If you have upper case letters, then yes...you will have to modify the code a little.

  • @vivekmalviya3036
    @vivekmalviya3036 5 місяців тому +1

    Bhai aap agar hindi me video banyenge to jyada views jayenga
    Kyoki leet code ke hindi me acche solution nhi h
    Thank u bhai

    • @nikoo28
      @nikoo28  5 місяців тому

      Do the subtitles help?