Easy 3 approaches with explanation | C++ | 100% time | One liner
Very Easy solutions with quick explanation \nApproach 1 Basic approach of counting frequency\nI have used array for this approach\n100% time for this approach\n
Very Easy solutions with quick explanation \n**Approach 1 Basic approach of counting frequency**\nI have used array for this approach\n100% time for this approach\n```\nclass Solution {\npublic:\n    bool checkIfPangram(string sentence) {\n        vector<int> v(26,0);\n        for(auto x:sentence)\n        {\n            v[x-\'a\'] = 1;\n        }\n        return accumulate(begin(v),end(v),0) == 26;\n    }\n};\n```\n**Approach**\nCounting all the unique charcters and check if they are equal to 26 (26 letters are there in the english alphabet series)\n\n**Working of code**\n**Step 1 :**\nCreate an int array of size 26 and fill with all 0s\n```\nv = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] length = 26\n```\n**Step 2:**\nIterate all the elements of given sentence and mark the character present in our array...\n\n```\nExample if we are at character \'g\'\nso ascii value of g = 103\nso we subtract ascii value of \'a\' (97) to get the correct index of g in our array\nso now it would be 6 (103-97 = 6)\nNow you can verify that 6 is the position of \'g\' in alphabetic sequence (0 based indexing)\n\n0 1 2 3 4 5 \'6\'\na b c d e f \'g\'\n\nso we put 1 at the position 6 in our array\nv = [ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] length = 26\n\n```\nNow we will fill all the position if the corresponding character is present in the string\n\n**Step 3:**\nNow we can sum up all the elements present in the array. so if any 0 left unchanged then the sum would not be equal to 26..\nAnd that\'s the strategy...\n<hr>\n\n**Approach 2 with integer variable as container**\n100% time for this approach\n```\nbool checkIfPangram(string sentence) {\n    int n = 0;\n    for(auto &x:sentence){\n        n|=(1<<(x-\'a\'));\n    }\n    cout<<n;\n    return n==67108863;\n}\n```\n**Approach**\nApproach is same but as we know integer variable can hold a number of 32 bits, so istead of using a vector of size 26, we can simply use the bits of integer as flag bits (If ith bit is set then ith char in alphabetic series is presnt in the string.\n**Working of code**\n**Step 1 :**\nCreate an int var and initialise with 0\n```\nHere our variable will start behaving like vector of bool of size 32\nbits of int will be\ni = bits(00000000000000000000000000000000)\n```\n**Step 2 :**\nNow we can run a for loop same as in approach 1 to iterte over the string\nAnd we will set the ith bit of the int variable\n```\nExample : if curr char is \'d\'\nthen position of \'d\' is 4 in alphabet series...\nSo we will try to set the 4th bit if it is 0 initially by using this\nn|=(1<<(x-\'a\'));\n\nHere in 1 all bits are zeroes and last bit is 1\nSo we move that last set bit to 4th position (for \'d\') (Here x-\'a\' will give the exact position of the bit)\nAfter this we will do bit wise OR with our number so that its ith bit will became 1\n```\n**Step 3 :**\nNow we can simply compare our number with 67108863...\nHere 67108863 is the number in which last 26 bits are 1\nSo if we reach the state where all 26 bits are 1 then we can conclude that we have iterated all the characters in the alphabet as we have done in previous approach\n\n<hr>\n\n**Approach 3 with set**\nThis is not the time optimised solution, still good if you are a lazy person when it comes to typing\n```\nbool checkIfPangram(string sentence) {\n        return unordered_set<char> (begin(sentence),end(sentence)).size()==26;\n}\n```\n\n**Approach**\nApproach is same but working is slightly different\n\n**Working**\n**Step 1:**\nCreate a set and fill it with all the characters present in the string..\n\n**Step 2:**\nAs per the property of sets you can not have duplicates in the set. \nSo you can simply check the size of set whether it has 26 unique elements or not\n\nTime Complexity is O(n) for all the approaches\n\n**NOTE :** If you find any errors or any improvements required, then feel free to comment down below.\n\nThanks\nGood Luck
['Array', 'Hash Table', 'C', 'Ordered Set', 'C++']