how to get last element of set
#include <iostream>
#include <set>
int main() {
std::set<int> mySet = {1, 2, 3, 4, 5};
auto it = mySet.end();
--it;
int lastElement = *it;
std::cout << "The last element is: " << lastElement << std::endl;
return 0;
}