Short Problem Definition:
There are n piles of stones, where the ith pile has ai stones. You need to collect the maximum number of stones from these piles
time complexity is
space complexity is
This challenge is fairly simple. It does not matter how those stones are arranged. The only important bit is that either the sum of all even elements is bigger than the sum of all odd elements or vice versa.
def maximumStones(arr): return 2*min(sum(arr[0::2]), sum(arr[1::2]))