Arrange Flower Sticks
Emma wishes to give her father a bouquet for his birthday. She asks for help from her mother Rosy. Rosy gives N flower sticks numbered 1 to N to Emma and tells her to arrange them in the bouquet in a particular order. She asks Emma to arrange the first K flower sticks in the order of increasing length and the remaining sticks in the order of decreasing length.
Write an algorithm to find the final arrangement of the flower sticks in the bouquet.
Input
The first line of the input consists of an integer - flowerStick_size, representing the number of flower sticks (N).
The second line consists of N space-separated integers- flowerStick[1], flowerStick[2],...,flowerStick[N], representing the length of the flower sticks.
The last line consists of an integer - random, representing the number K given by Rosy to Emma.
Output
Print N space-separated integers representing the final arrangement of the flower sticks in the bouquet.
Constraints
0 ≤ random ≤flowerStick_size
0 < flowerStick_size < 10^>6
1Example 1
Constraints
Limits and guarantees your solution can rely on.
0 ≤ random ≤flowerStick_size
0 < flowerStick_size < 106