Hash Tables: Ransom Note

  • + 1 comment

    The reason you want to use a map or something like it is because a map has constant time insertion and lookup. This makes your algortihm using a map for this O(n). Any sorting algorithm will be O(nlogn) so it has a slower runtime.