C++ - Easiest Beginner Friendly Sol || Hash Table || O(n) time and O(1) space
Intuition of this Problem:\n Describe your first thoughts on how to solve this problem. \nNOTE - PLEASE READ APPROACH FIRST THEN SEE THE CODE. YOU WILL DEFINITE
# Intuition of this Problem:\n<!-- Describe your first thoughts on how to solve this problem. -->\n**NOTE - PLEASE READ APPROACH FIRST THEN SEE THE CODE. YOU WILL DEFINITELY UNDERSTAND THE CODE LINE BY LINE AFTER SEEING THE APPROACH.**\n\n# Approach for this Problem:\n1. Initialize two variables n and m to store the length of strings s and t respectively.\n2. Check if the length of the two strings is not equal, return false as they cannot be anagrams.\n3. Initialize a count array of size 26 with all values set to 0.\n4. Loop through the two strings and increment the count of characters of s and decrement the count of characters of t in the count array.\n5. Call the function allZeroes to check if all the values in the count array are 0. If allZeroes returns false, return false as they are not anagrams.\n6. If all values in the count array are 0, return true as they are anagrams.\n<!-- Describe your approach to solving the problem. -->\n\n# Humble Request:\n- If my solution is helpful to you then please **UPVOTE** my solution, your **UPVOTE** motivates me to post such kind of solution.\n- Please let me know in comments if there is need to do any improvement in my approach, code....anything.\n- **Let\'s connect on** https://www.linkedin.com/in/abhinash-singh-1b851b188\n\n![57jfh9.jpg](https://assets.leetcode.com/users/images/c2826b72-fb1c-464c-9f95-d9e578abcaf3_1674104075.4732099.jpeg)\n\n# Code:\n```C++ []\nclass Solution {\npublic:\n    bool allZeroes(vector<int>& count) {\n        for (int i = 0; i < 26; i++) {\n            if(count[i] != 0)\n                return false;\n        }\n        return true;\n    }\n    bool isAnagram(string s, string t) {\n        int n = s.length();\n        int m = t.length();\n        if(n != m)\n            return false;\n        vector<int> count(26, 0);\n        for (int i = 0; i < n; i++) {\n            count[s[i] - \'a\']++;\n            count[t[i] - \'a\']--;\n        }\n        if(allZeroes(count) == false)\n            return false;\n        return true;\n    }\n};\n```\n```Java []\nclass Solution {\n    public boolean allZeroes(int[] count) {\n        for (int i = 0; i < 26; i++) {\n            if(count[i] != 0)\n                return false;\n        }\n        return true;\n    }\n    public boolean isAnagram(String s, String t) {\n        int n = s.length();\n        int m = t.length();\n        if(n != m)\n            return false;\n        int[] count = new int[26];\n        for (int i = 0; i < n; i++) {\n            count[s.charAt(i) - \'a\']++;\n            count[t.charAt(i) - \'a\']--;\n        }\n        if(allZeroes(count) == false)\n            return false;\n        return true;\n    }\n}\n\n```\n```Python []\nclass Solution:\n    def allZeroes(self, count):\n        for i in range(26):\n            if count[i] != 0:\n                return False\n        return True\n\n    def isAnagram(self, s: str, t: str) -> bool:\n        n = len(s)\n        m = len(t)\n        if n != m:\n            return False\n        count = [0] * 26\n        for i in range(n):\n            count[ord(s[i]) - ord(\'a\')] += 1\n            count[ord(t[i]) - ord(\'a\')] -= 1\n        if self.allZeroes(count) == False:\n            return False\n        return True\n\n```\n\n# Time Complexity and Space Complexity:\n- Time complexity: **O(|s| + |t|)**\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: **O(26) = O(1)**\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->
['Hash Table', 'String', 'C++', 'Java', 'Python3']