![]() |
In C++, sets are STL containers that store unique elements of the same type in a sorted manner. No duplicate elements are allowed in the sets, as the value of every element in a set is unique. In this article, we will learn how we can find the size of a set container in C++. Example: Input: mySet={1,2,3,4,5,6,7,8} Output: The size of mySet is: 8 Find the Size of a Set in C++The size of the set container refers to the number of elements currently present in it. The std::set container provides a member function named std::set::size() which returns the size of the set or the number of elements in the set. Syntax of std::set::size()set_name.size() C++ Program to Find the Size of a SetC++
Output
Size of the set is : 8 Time Complexity : O(1) |
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |