Lesson 11 of 24

STL Algorithms: sort, reverse आणि find

10 min 30 XP

<algorithm> तुम्हाला तयार sort, reverse, max_element, min_element, count, find आणि binary_search देते; <numeric> accumulate जोडते. एक ओळ, भरपूर काम.

Example: edit me and press Run

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.

sort() O(n log n) मध्ये चालते. binary_search फक्त sorted range वर चालते.

Challenge

+30 XP

n आणि n संख्या वाचा. वेगवेगळ्या values चढत्या क्रमाने print करा, मग पुढच्या ओळीत किती वेगवेगळ्या values आहेत. Input: 7 4 1 4 2 1 9 2 Output: 1 2 4 9 4

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.