diff --git a/python/2017-Grid-Game.py b/python/2017-Grid-Game.py new file mode 100644 index 000000000..edce10fdb --- /dev/null +++ b/python/2017-Grid-Game.py @@ -0,0 +1,12 @@ +# Time: O(n) Space: O(1) + +class Solution(object): + def gridGame(self, grid): + result = float("inf") + left, right = 0, sum(grid[0]) + + for a, b in zip(grid[0], grid[1]): + right -= a + result = min(result, max(left, right)) + left += b + return result