[DAY20]Hash Tables: Ice Cream Parlor

Sherlock Chiou
1 min readOct 22, 2019

--

Solution1: Sorted and Binary Search.

Solution 2: Create a hash table to record the position of each cost. And traverse through the hash table. Find if the value of money minus cost exits in the keys of the has table. Also we need to further check if the cost equals money minus cost. An exception might happens when the value of money minus cost equals cost, and only one of the ice cream cost that.

--

--

Sherlock Chiou
Sherlock Chiou

Written by Sherlock Chiou

Be Effective and Optimize for Learning

No responses yet