注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 George_333 于 2025-9-24 14:13 编辑
两道easy 新人求加米!
A player is playing a game in which coins are placed on and removed from a table. The game may consist of multiple rounds. At the beginning of each round the table is empty. There are three possible types of events:
"i": increase, one additional coin is placed on the table.
"d": decrease, a single coin is taken from the table. If the table is empty, nothing happens.
"w": win, the player wins the round and takes all coins that are currently on the table.
Write a function:
deould be (0, 0, -1).
Then, out of the five remaining zeros, only three can be selected (otherwise some would overlap).
The function should return 2.
A = [-1, 3, -1, 2, -1, 0, -3]
Only one triplet (-1, -2, 3) can be selected.
The function should return 1.
A = [-1, -2, 3, -1, 0, 1]
The function should return 2. |