Best Optimal solution to identify if two strings are anagram using alphabets array with time complexity O(n) DSA and Algo Playlist: • How I Cracked Google ?...
Harshal da .... I m from the same village as of yours ... And currently studying my degree in CSE at Pune ..... Will try my best to get employed at Google and will always be in search of opportunity .... Experience shared by you through your video of how to get placed in Google and what type of format it required also cleared many queries .... Thank you ✌️
One approach can be taking the sum of ASCII values of both strings and compare the sum. If sum of both strings is equal it's anagram else not an anagram
Thanks Madhukar for this approach. On high level, below is the logic/code int sum1 = 0; int sum2 = 0; for (char c : string1.toCharArray()) sum1 = sum1 + c; for (char c : string2.toCharArray()) sum2 = sum2 + c; return sum1 == sum2;