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
@nikoo289 ай бұрын
Excellent
@inspiredomkar1239 Жыл бұрын
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.
@cremewe67008 ай бұрын
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.
@nikoo288 ай бұрын
Is there an AI tool that did this automatically?
@praveenraja8597 ай бұрын
@@nikoo28
@sasidharnaidu45077 ай бұрын
You can add one more if statement that if length of str less than 26, return false
@tanishkaagarwal6750 Жыл бұрын
Thank you so much sir. Your teaching style is awesome.
@nikoo28 Жыл бұрын
So nice of you
@shwetasdhake79864 ай бұрын
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.
@pavankumarpadamati86069 ай бұрын
But it is taking time i.e like 7ms like that .. public boolean checkIfPangram(String sentence) { for(char i='a';i
@prabirmaity4529 Жыл бұрын
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 ?