Algorithms and Data Structures

• Status
• 1
Implementation
• 2
Bitwise operations
• 3
Prefix Sums
• 4
Sliding window / Two pointers
• 5
Modular Arithmetic
• 6
Number Theory
• 7
Binary Search
• 8
Basic Sorting
• 9
Greedy Algorithms
• 10
Basic Dynamic Programming
• 11
Recursion
• 12
• 13
Queue & Stack
• 14
Binary tree + BST
• 15
Divide & Conquer + Advanced Sorting
• 16
Heap
• 17
Hashing
• 18
Graph Representation
• 19
BFS

• # Implementing a custom sorting algorithm

We can try to implement a very simple sorting algorithm ourselves:
• On each iteration select the smallest element from the array
• Add that to the result
• Remove that element from the initial array
Repeat this process as many times as the number of elements in the initial array, and we’ll obtain a perfectly sorted array.

#### Input

The first line of the input contains a single integer `n` (1 ≤ n ≤ 1000) the number of elements in the array.
The next line contains `n` space-separated integers ().

#### Output

The program should print the array in the input sorted in increasing order.

#### Examples

 Input Output 5 5 5 3 2 3 2 3 3 5 5

#### Constraints

Time limit: 1 seconds

Memory limit: 512 MB

Output limit: 1 MB
{"ft_lang_label":"__label__en","ft_lang_prob":0.73650277,"math_prob":0.88045967,"size":738,"snap":"2023-14-2023-23","text_gpt3_token_len":182,"char_repetition_ratio":0.12806539,"word_repetition_ratio":0.02962963,"special_character_ratio":0.24525745,"punctuation_ratio":0.06382979,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9689176,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-04-02T11:33:49Z\",\"WARC-Record-ID\":\"<urn:uuid:5b953d44-c8a0-46ee-bb1d-e71de2a952b9>\",\"Content-Length\":\"137159\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c3c3dbfa-0243-4ab3-8f04-3005384e594e>\",\"WARC-Concurrent-To\":\"<urn:uuid:48f8860f-c46d-46ff-8393-e77c92128080>\",\"WARC-IP-Address\":\"76.76.21.21\",\"WARC-Target-URI\":\"https://profound.academy/algorithms-data-structures/zBYGNgpzcU4VL5paVV9p\",\"WARC-Payload-Digest\":\"sha1:FFCYMH4XZILA2LEM47ZP4DGSXFBQESSU\",\"WARC-Block-Digest\":\"sha1:US46TOEOZMU5UMEYVV3FJ5TZCBTGIASR\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296950528.96_warc_CC-MAIN-20230402105054-20230402135054-00231.warc.gz\"}"}