welcome to
evildojo


HackerRank

Cracking the Coding Interview

Hash Tables: Ransom Note

Located here: https://www.hackerrank.com/challenges/ctci-ransom-note

Notes:

This example is done in Python.


Not formatting the problem text. Read the link. I am too lazy.


I'm still having problems getting all of the solution sets to process correctly.

Here is my current solution:

def ransom_note(magazine, ransom):
new_list = []
ransom.sort()
magazine.sort()
for w in ransom:
    if w in magazine:
        new_list.append(magazine.pop(magazine.index(w)))
return new_list == ransom

Note that I am not using a hash table here, so I am likely missing something...