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
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.
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 ?
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.
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
Excellent
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.
You can add one more if statement that if length of str less than 26, return false
Thank you so much sir. Your teaching style is awesome.
So nice of you
Love You Respected SIr.
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
Bro ..please do video on Leetcode #2384 - Largest Palindromic Number . I did got this in the interview..
What interview did you get this in?
@@nikoo28 got that in the Citi bank coding test.
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.
Is there an AI tool that did this automatically?
@@nikoo28
But it is taking time i.e like 7ms like that .. public boolean checkIfPangram(String sentence) {
for(char i='a';i
Got this question in my last OA round
What company?
@@nikoo28 Xactly
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 ?
yes, that approach is also correct. :)
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.
Thank you so much
Sir, Please explain " 36. Valid Sudoku " problem from leetcode
sure, I will add it to my list of upcoming videos
Good Job Man!
Thanks!
Bhai aap agar hindi me video banyenge to jyada views jayenga
Kyoki leet code ke hindi me acche solution nhi h
Thank u bhai
Do the subtitles help?
Its z sir not g
what if the string contains some upper case letters
Just convert the character x to lower
always check the problem constraints. If you have upper case letters, then yes...you will have to modify the code a little.