Skip to content

Commit 0f59579

Browse files
authored
Create stone-game-vi.py
1 parent 8cc6bd3 commit 0f59579

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Python/stone-game-vi.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Time: O(nlogn)
2+
# Space: O(n)
3+
4+
class Solution(object):
5+
def stoneGameVI(self, aliceValues, bobValues):
6+
"""
7+
:type aliceValues: List[int]
8+
:type bobValues: List[int]
9+
:rtype: int
10+
"""
11+
sorted_vals = sorted(((a, b) for a, b in zip(aliceValues, bobValues)), key=sum, reverse=True)
12+
return cmp(sum(a for a, _ in sorted_vals[::2]), sum(b for _, b in sorted_vals[1::2]))

0 commit comments

Comments
 (0)