Check if string is pangram | String Interview Question

preview_player
Показать описание
JOIN ME
—————

COMPLETE PLAYLIST
————————————

INTERVIEW PLAYLIST
————————————

QUICK SHORT VIDEOS
————————————-

In this video we will learn how to check if given string is pangram or not.
I have explained a very simple and faster approach to this problem.

#cpp #string #programming #interviewquestion #computerscience
Рекомендации по теме
Комментарии
Автор

Sir this is simplist that anyone has explain all salo auro ko khud nhi pta ky bol rhe hai really thank you appreciate❤😊

axx
Автор

you were solving this question on leetcode and today i did the same solution as yours which beats only 20% in both time an space,
best solution would be:
int arr[26]={0};
for(int i=0;i<sentence.length();i++)
{
arr[sentence[i]-97]++;
}
for(int i=0;i<26;i++)
{
if(arr[i]==0) return false;
}
return true;

photos
Автор

What if you do :
std::map<char, bool> myMap;
for each character {
myMap[e] = true;
}
return myMap.Size() == 26

Is it faster ?

alexandresendra
Автор

My psudo solution:
unordered_set<char> tset;
for(const auto& ch : input_str){
tset.insert(tolower(ch));
return true if tset.size()==26;
}
return false;

aby_yadav
Автор

I think your algorithm will continue checking for the whole string(lets say length is and what will happen if the first 26 elements will already have A-Z ? then we keep on checking the rest of string? i think it might be unnecessary. I would prefer vector to be int rather than bool and for every first time we encounter new letter I will increment counter and when counter reaches 26 i will return true. if not false.

nikhilreddy