Arrange all odd number in descending and arrange all even number in asscending and concatenate them



Problem to arrange all odd number in descending and arrange all even number in asscending and concatenate them



Example-1:


Input    : n = [ 1, 2, 3, 4, 5]
Output   : [5,3,1,2,4]    


Example-2:


Input    : n = [ 6, 7, 8, 9]
Output   : [9,7,6,8]     







Solution





n = [ 1, 2, 3, 4, 5]

l = []

k = []

for i in range(len(n)):

    if(n[i] % 2 == 0):

        l.append(n[i])

    else:

        k.append(n[i])

m = k[::-1] + l

print(m)



Output



[5,3,1,2,4]