Skip to content

Commit fe705aa

Browse files
authored
Create Buy two chololates.cpp
1 parent 5d650eb commit fe705aa

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Buy two chololates.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
int buyChoco(vector<int>& prices, int money) {
4+
sort(prices.begin(),prices.end());
5+
int m_cost=prices[0]+prices[1];
6+
if(m_cost<=money)
7+
{
8+
return money-m_cost;
9+
}
10+
else
11+
{
12+
return money;
13+
}
14+
}
15+
};

0 commit comments

Comments
 (0)