Google L3/ L4 Phone Screen
Anonymous User
1772

Implement the class BestAnagramFinder, which takes a list of words named as 'dictionary' as a parameter while initialization. The class has the below methods:

  1. hashAnagram: an abstract method which takes a 'word' as a parameter and returns the hash value of the word.
  2. calculateScore: a method which takes a 'word' as input and calculates the score of it. The score is calculated by adding up all the absolute distance of the adjacent characters in the word.
  3. findBestAnagram: a method that takes a 'word' as input and returns the best anagram for the 'word' (best anagram is the word which has the maximum score).
Comments (5)