Skip to content

Commit

Permalink
Create ICE_CREAM_PARLOUR.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Priyanshiguptaaa authored Dec 4, 2020
1 parent 8d3aca4 commit 4ec1fdd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions HASH_MAPS/ICE_CREAM_PARLOUR.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
void whatFlavors(vector<int> cost, int money)
{
int firstpick = 0;
int secondpick;
unordered_map<int,int> costTofavor;
for(int i=0;i<cost.size();i++)
{
secondpick = i;
if(costTofavor.count(money-cost[i]))
{
firstpick = costTofavor[money-cost[i]];
cout<<firstpick+1<<" "<<secondpick+1<<endl;
return;
}
costTofavor[cost[i]]=i;
}
return;
}

0 comments on commit 4ec1fdd

Please sign in to comment.