Reorder an array such that sum of left half is not equal to sum of right half | Function to print the required reordering of the array if possible ; Sort the array in increasing order ; If all elements are equal , then it is not possible ; Else print the sorted array arr [ ] ; Driver Code ; Given array ; Function Call
def printArr ( arr , n ) : NEW_LINE INDENT arr . sort ( ) NEW_LINE if ( arr [ 0 ] == arr [ n - 1 ] ) : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " Yes " ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = " ▁ " ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 2 , 1 , 3 , 1 ] NEW_LINE N = len ( arr ) NEW_LINE printArr ( arr , N ) NEW_LINE DEDENT