Goldman Sachs interview question

Write a program that accepts 2 strings and returns true if one is an anagram of another

Interview Answer

Anonymous

1 Feb 2017

So I can't give a concrete answer in C++ because I do not know it well enough, but here's an answer that applies to Python/Java. You'll just have to go one abstraction layer lower to answer in C++ Think about it abstractly: What does it mean for a word to be an anagram of another word? Answer: the words must have the same letters, but in different arrangements So we use this more concrete description to implement our answer. 1. Convert both strings to hashmaps, with the keys being chars and the values being the number of occurrences 2. Return the boolean that the first hashmap is equal to the second hashmap (i.e. shares keys and corresponding values)