added O(n) algorithm to check anagram