这道题深刻的诠释了什么才叫简单题!!!!!!!
之前做的那些叫什么简单题啊!!!!!!
class Solution:
def lemonadeChange(self, bills: List[int]) -> bool:
if(bills[0]!=5):
return False
else:
five = 1
ten = 0
twenty = 0
for i in range(1,len(bills)):
if(bills[i]==10 and five>=1):
five -= 1
ten += 1
elif(bills[i]==20 and five>=1 and ten>=1):
five-=1
ten-=1
elif(bills[i]==20 and five>=3):
five-=3
elif(bills[i]==5):
five+=1
else:
return False
return True
做完看了评论区,这题真没啥技巧,大家想法都一样,希望复试就考这种题谢谢