how to get last element of set in c++

C++
set<int> s = {1,2,3}
auto it = s.end();
it--;
cout<<*it<<"\n"; // This refers to last element of a setlist.get(0);const nums = [1, 2, 3, 4, 5, 6, 7];
const lastOne = nums[nums.lenght - 1]; // last element of array!list_or_set.isEmpty()
Source

Also in C++: