We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
(C++) This is technically this is O(n*m) where n is the number of words and m is the size of the word. This would mean n*m is the number of charcters in the line, so this is O(n). You also don't need to do weird stuff to toss out the whitespace like you would if you saved a string with getline.
// a is index 0, b is index 1, ... etc// we use this to check if it was used in the lineboolalphabet[26]={false};stringword;while(cin>>word){// let cin ignore whitespacefor(inti=0;i<word.length();i++){// this will give the an index between 0 and 25intposition=tolower(word[i])-'a';alphabet[position]=true;}}for(inti=0;i<26;i++){// if there was a letter not includedif(!alphabet[i]){cout<<"not pangram"<<endl;return0;}}cout<<"pangram"<<endl;return0;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Pangrams
You are viewing a single comment's thread. Return to all comments →
(C++) This is technically this is O(n*m) where n is the number of words and m is the size of the word. This would mean n*m is the number of charcters in the line, so this is O(n). You also don't need to do weird stuff to toss out the whitespace like you would if you saved a string with getline.