human
Lexicographically smallest permutation having maximum sum of differences between adjacent elements | Function to find the lexicographically smallest permutation of an array such that the sum of the difference between adjacent elements is maximum.
Stores the size of the array.
Sort the given array in increasing order.
Swap the first and last array elements.
Print the required permutation.
Driver Code"
Solution in Python:
 ... What is a code to lexicographically smallest permutation having maximum sum of differences between adjacent elements and the other steps required?
assistant
#Here is code to lexicographically smallest permutation having maximum sum of differences between adjacent elements and the other steps required.
 def maximumSumPermutation ( arr ) :
	N = len ( arr ) ;
	arr . sort ( ) ;
	temp = arr [ 0 ] ;
	arr [ 0 ] = arr [ N - 1 ] ;
	arr [ N - 1 ] = temp ;
	for i in arr :
		print ( i , end = " ▁ " ) ;
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 3 , 4 , 5 ] ;
	maximumSumPermutation ( arr ) ;