-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
33 lines (29 loc) · 839 Bytes
/
test.cpp
File metadata and controls
33 lines (29 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<bits/stdc++.h>
using namespace std;
int main () {
vector<int>v;
v.push_back(10);
v.push_back(10);
// v.push_back(45);
// v.push_back(90);
// v.push_back(31);
for(int i : v ) cout<< i<< " ";
cout << endl;
sort(v.begin(),v.end());
cout<<v.size()<<endl;
cout<<v.at(v.size()-2);
return 0;
}
//int getSecondLargest(vector<int> &arr) {
// // Code Here
// set<int> uniqueElements(arr.begin(), arr.end());
//
// // If there are less than two unique elements, return -1
// if (uniqueElements.size() < 2) return -1;
//
// // Convert set to vector and sort
// vector<int> uniqueVec(uniqueElements.begin(), uniqueElements.end());
// sort(uniqueVec.begin(), uniqueVec.end());
//
// // Return the second last element (second largest)
// return uniqueVec.at(uniqueVec.size() - 2);