Dcoder icon

Avik and his Girlfriend's Necklace @ Dcoder

By Lochard | As a newbie programmer | 9 Jul 2023


Problem: Avik's Girlfriend is a Sorted Girl and she is also a Coder and loves arrays. So on her birthday Avik decided to gift her a necklace of pearls, now these pearls have numbers printed on them. When he bought the necklace its pearls were in sorted order, as his girlfriend likes, but while he was showing it to her on the day of birthday, it fell down and all the pearls scattered. Seeing this his girlfriend started crying, so he promised her that he will correct this. Now Avik dont know sorting, your job is to sort these peaarls so that he could make the necklace back and make his girlfriend happy.

Input: First line conains N, no. of element/pearls , next line contains N integer separated by space, to be sorted.

Output: print the sorted integers.

Constraints: 1<=N<=100

PS: Try improving your algorithm by using a more efficient sort algo.

Sample Input: 5

1 5 7 3 4

Sample Output: 

1 3 4 5 7

input()
print(' '.join(sorted(input().split())))

How do you rate this article?

3


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.