MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / getMoneySpent

Function getMoneySpent

Hackerrank_problems/ElectronicShop/solution2.py:26–37  ·  view source on GitHub ↗
(keyboards, drives, b)

Source from the content-addressed store, hash-verified

24
25#getMoneySpent() will return the amount required to buy the most expensive keyboard and USB drive. If not not possible returns -1.
26def getMoneySpent(keyboards, drives, b):
27 moneyspent=-1 #maximum amount of money spent
28 drives.sort()
29 for num in keyboards:
30 price=check(drives,0,m-1,b-num,-1) #price=price of most expensive USB drive that can be bought after purchasing the keyboard of price num
31 if price==-1:
32 continue
33 exp=price+num #exp=expense after buying both the items
34 if exp>moneyspent:
35 moneyspent=exp
36
37 return moneyspent
38
39
40#input part fot the given problem

Callers 1

solution2.pyFile · 0.70

Calls 2

sortMethod · 0.80
checkFunction · 0.70

Tested by

no test coverage detected