Solutions for Modify the Array

    • @MatthewIdete
    • @alexander, submitted in Python 3, achived 100% score
    def solve(arr): 
        n = len(arr)
        max_idx = n - 1
        min_idx = 0
        max_elem = arr[n-1] + 1
        for i in range(0, n) : 
            if i % 2 == 0 : 
                arr[i] += (arr[max_idx] % max_elem ) * max_elem 
                max_idx -= 1
            else : 
                arr[i] += (arr[min_idx] % max_elem ) * max_elem 
                min_idx += 1
        for i in range(0, n) : 
            arr[i] = arr[i] / max_elem 
        A=[int(a) for a in arr]
        return A