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

  Рет қаралды 8,025

Nikhil Lohia

Nikhil Lohia

Күн бұрын

Пікірлер: 32
@rajeevmishra5649
@rajeevmishra5649 10 ай бұрын
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 9 ай бұрын
Excellent
@inspiredomkar1239
@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.
@cremewe6700
@cremewe6700 8 ай бұрын
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 8 ай бұрын
Is there an AI tool that did this automatically?
@praveenraja859
@praveenraja859 7 ай бұрын
@@nikoo28
@sasidharnaidu4507
@sasidharnaidu4507 7 ай бұрын
You can add one more if statement that if length of str less than 26, return false
@tanishkaagarwal6750
@tanishkaagarwal6750 Жыл бұрын
Thank you so much sir. Your teaching style is awesome.
@nikoo28
@nikoo28 Жыл бұрын
So nice of you
@shwetasdhake7986
@shwetasdhake7986 4 ай бұрын
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.
@pavankumarpadamati8606
@pavankumarpadamati8606 9 ай бұрын
But it is taking time i.e like 7ms like that .. public boolean checkIfPangram(String sentence) { for(char i='a';i
@prabirmaity4529
@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 ?
@nikoo28
@nikoo28 Жыл бұрын
yes, that approach is also correct. :)
@thugesh123-12
@thugesh123-12 3 ай бұрын
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
@arslanmuhammad4190
@arslanmuhammad4190 Жыл бұрын
Love You Respected SIr.
@hoddybhaba6704
@hoddybhaba6704 Жыл бұрын
Bro ..please do video on Leetcode #2384 - Largest Palindromic Number . I did got this in the interview..
@nikoo28
@nikoo28 Жыл бұрын
What interview did you get this in?
@hoddybhaba6704
@hoddybhaba6704 Жыл бұрын
@@nikoo28 got that in the Citi bank coding test.
@Bhavya__Garg
@Bhavya__Garg Жыл бұрын
Sir, Please explain " 36. Valid Sudoku " problem from leetcode
@nikoo28
@nikoo28 Жыл бұрын
sure, I will add it to my list of upcoming videos
@shivanimishra2448
@shivanimishra2448 Жыл бұрын
Got this question in my last OA round
@nikoo28
@nikoo28 Жыл бұрын
What company?
@shivanimishra2448
@shivanimishra2448 Жыл бұрын
@@nikoo28 Xactly
@ashishgaikwad8857
@ashishgaikwad8857 9 ай бұрын
Thank you so much
@vivekmalviya3036
@vivekmalviya3036 6 ай бұрын
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 6 ай бұрын
Do the subtitles help?
@SergekSh
@SergekSh Жыл бұрын
Good Job Man!
@nikoo28
@nikoo28 Жыл бұрын
Thanks!
@sagarswagatsahoo4774
@sagarswagatsahoo4774 9 ай бұрын
Its z sir not g
@himanshugupta5998
@himanshugupta5998 11 ай бұрын
what if the string contains some upper case letters
@aayushraj2918
@aayushraj2918 11 ай бұрын
Just convert the character x to lower
@nikoo28
@nikoo28 10 ай бұрын
always check the problem constraints. If you have upper case letters, then yes...you will have to modify the code a little.
Pangram Program in Java | Pangram Problem Solution | Interview Questions on Pangram | ABC
16:53
ABC - Technology Training & Upskilling
Рет қаралды 56 М.
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 183 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 119 МЛН
PROBABILITY CLASS 1
1:39:19
vishal sharma classes
Рет қаралды 32
Java Program to check given String is Panagram or not?
8:24
Learn With KrishnaSandeep
Рет қаралды 59 М.
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59