Created
September 2, 2019 18:32
-
-
Save wenweixu/5e2253ee3cf7914995156529bb48fbfa to your computer and use it in GitHub Desktop.
Hackerrank Hash Tables - Ice Cream Parlor Python solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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