Problem Description
Given an integer array A consisting of distinct elements.
You are asked to create a lexicograhically largest array S = X + reverse(Y) ('+' denotes concatenation) such that it satisfies the following conditions:
Note: Array X or Y can be empty.
1 <= len(A) <= 105
1 <= A[i] <= 109
First and only argument is an integer array A.
Return an integer array denoting the lexicographically largest array S.
Input 1:
A = [4, 1, 3, 2]
Input 2:
A = [10, 20, 30, 40]
Output 1:
[4, 2, 3, 1]
Output 2:
[40, 30, 20, 10]
Explanation 1:
X = [4], Y = [1, 3, 2]. Reverse(Y) = [2, 3, 1] S = X + Reverse(Y) = [4, 2, 3, 1]
Explanation 2:
X = [], Y = [10, 20, 30, 40]. Reverse(Y) = [40, 30, 20, 10] S = [40, 30, 20, 10]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.