Given an array of integers A, the task is to output another array B of the same length so that B[i] is the maximum over A for every index that is not i. That is \$B[i] = \max_{i' \ne i} A[i']\$.
Examples:
A = [1, 5, -3, 4, 2]. B = [5, 4, 5, 5, 5] A = [1, 2, 3]. B = [3, 3, 2] A = [-1, -2, -3, -1]. B = [-1, -1, -1, -1] The restriction is that your code must run in linear time in the length of the input array A.
The input will always contain at least two integers.