Java easy to understand approach
Intuition\n Describe your first thoughts on how to solve this problem. \nthis solution been hard for me to apply since this is my first time indexing arrays thi
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nthis solution been hard for me to apply since this is my first time indexing arrays this way but it\'s a great method to calculate occurence in Strings.\nFollow along i will explain it.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n#### first step is to see if length of both strings isnt equal\nif thy are not we return false because they can\'t be anagrams if they are not composed of same length of caracters\n\n### Since the english alphabet contains 26 letters so we declared an arrays of length 26 and used ASCII to index it.\nhow?  since the test case is only made of lowerCase caracters\nwe substract the current element we\'re indexing from \'a\'.\nthe a character has ascii of 97 if for example we want to get to the index of letter \'c\'  that has ascii 99 we do \'c\'-\'a\' which is in ascii 99 - 97 it return  2 which is the index of letter c third element of the alphabet .\nwe broke the hard part apart now we must calculate the occurence.\neach time we index on i element of string with the trick i explained earlier we increment the count by one;\nwe do the same thing with other string but we decrement , why? so if they are equal the array will contains zeros in that case only we can say that Strings are equal.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(k+n) = O(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1) because the space used by the char_sequence array is fixed.\n# Code\n```\nclass Solution {\n    public boolean isAnagram(String s, String t) {\n       if(s.length()!= t.length()) return false;\n       int [] char_sequence = new int[26];\n       for(int i =0 ; i<s.length();i++){\n            char_sequence[s.charAt(i)-\'a\']++;\n            char_sequence[t.charAt(i)-\'a\']--;\n       }\n       for(int i = 0 ; i<char_sequence.length ; i++){\n           if(char_sequence[i]!=0){\n               return false;\n           }\n       }\n       return true;\n    }\n}\n```\n# Please UPVOTE\n![image.png](https://assets.leetcode.com/users/images/2390c511-287a-47b4-8b7e-bcf883e4ef27_1685717190.824564.png)\n\n
['Java']