We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
To solve this, I used a dict (Python version of hashtable) that had the cost as the key and the value was a space separated string of all the indices where that cost occured in the list.. Then it was simply a matter of splitting that string and printing the first two elements if cost_i==money-cost_i
Hash Tables: Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
To solve this, I used a dict (Python version of hashtable) that had the cost as the key and the value was a space separated string of all the indices where that cost occured in the list.. Then it was simply a matter of splitting that string and printing the first two elements if cost_i==money-cost_i