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.