Skip to content

Instantly share code, notes, and snippets.

@wenweixu
Created September 2, 2019 18:32
Show Gist options
  • Save wenweixu/5e2253ee3cf7914995156529bb48fbfa to your computer and use it in GitHub Desktop.
Save wenweixu/5e2253ee3cf7914995156529bb48fbfa to your computer and use it in GitHub Desktop.
Hackerrank Hash Tables - Ice Cream Parlor Python solution
def whatFlavors(cost, money):
cost_dict = {}
for i,icost in enumerate(cost):
if money-icost in cost_dict:
print(str(cost_dict[money-icost]+1) + ' ' + str(i+1))
return
else:
cost_dict[icost] = i
@Yukta2001
Copy link

can u plz explain the working after the statement "if money-icost in cost_dict:"
Actually I couldn't get what is happening from this line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment