DEV Community

Discussion on: Solution: Valid Anagram

Collapse
 
vansikagupta profile image
Vansika Gupta

Since lower case letters are only 26 in number, we can use an array of size 26 instead and for getting the right index, we can subtract 97 from the ASCII code. So 'a''s index would become 97-97 = 0. Might not be significant but still an optimization.