五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

LeetCode 2660. Determine the Winner of a Bowling Game

2023-05-02 13:56 作者:您是打尖兒還是住店呢  | 我要投稿

You are given two?0-indexed?integer arrays?player1?and?player2, that represent the number of pins that player 1 and player 2 hit in a bowling game, respectively.

The bowling game consists of?n?turns, and the number of pins in each turn is exactly?10.

Assume a player hit?xi?pins in the?ith?turn. The value of the?ith?turn for the player is:

  • 2xi?if the player hit?10?pins in any of the previous two turns.

  • Otherwise, It is?xi.

The score of the player is the sum of the values of their?n?turns.

Return

  • 1?if the score of player 1 is more than the score of player 2,

  • 2?if the score of player 2 is more than the score of player 1, and

  • 0?in case of a draw.

?

Example 1:

Input:?

player1 = [4,10,7,9], player2 = [6,5,2,3]

Output: 1

Explanation:?

The score of player1 is 4 + 10 + 2*7 + 2*9 = 46.?

The score of player2 is 6 + 5 + 2 + 3 = 16.?

Score of player1 is more than the score of player2,?

so, player1 is the winner, and the answer is 1.

Example 2:

Input: player1 = [3,5,7,6], player2 = [8,10,10,2]

Output: 2

Explanation:?

The score of player1 is 3 + 5 + 7 + 6 = 21.?

The score of player2 is 8 + 10 + 2*10 + 2*2 = 42.?

Score of player2 is more than the score of player1, so, player2 is the winner, and the answer is 2.

Example 3:

Input: player1 = [2,3], player2 = [4,1]

Output: 0

Explanation:?

The score of player1 is 2 + 3 = 5?

The score of player2 is 4 + 1 = 5?

The score of player1 equals to the score of player2, so, there is a draw, and the answer is 0.

?

Constraints:

  • n == player1.length == player2.length

  • 1 <= n <= 1000

  • 0 <= player1[i], player2[i] <= 10

easy題目,主要是判斷保齡球的計(jì)算規(guī)則即可,就是每次出現(xiàn)10分的時(shí)候,后面2輪的分?jǐn)?shù)要翻倍,這里用一個(gè)臨時(shí)變量去處理即可;

下面是代碼:

Runtime:?2 ms, faster than?99.91%?of?Java?online submissions for?Determine the Winner of a Bowling Game.

Memory Usage:?43 MB, less than?37.94%?of?Java?online submissions for?Determine the Winner of a Bowling Game.


LeetCode 2660. Determine the Winner of a Bowling Game的評論 (共 條)

分享到微博請遵守國家法律
富阳市| 府谷县| 池州市| 丹棱县| 泾源县| 尉氏县| 阿瓦提县| 寿光市| 城市| 泊头市| 英山县| 游戏| 大丰市| 连城县| 嘉祥县| 禄丰县| 无为县| 北流市| 开化县| 梁山县| 汕尾市| 宁远县| 内黄县| 沙河市| 晋宁县| 句容市| 和田市| 三门县| 房山区| 乌鲁木齐市| 利川市| 鄱阳县| 景宁| 金堂县| 望城县| 通河县| 监利县| 彩票| 太白县| 宣化县| 育儿|