Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
major element
//Title of this code #include <iostream> #include <map> #include <vector> using namespace std; int majorElemet(const vector<int>& t) { map<int, int> m; for (int i = 0; i < t.size(); ++i) if (m.find(t[i]) != m.end()) ++m[t[i]]; else m[t[i]] = 1; int biggest = 0; int num = -1; for (auto it = m.begin(); it != m.end(); ++it) if (it->second > biggest) { biggest = it->second; num = it->first; } return num; } int main() { vector<int> t; t.push_back(1); t.push_back(1); t.push_back(5); t.push_back(2); t.push_back(2); t.push_back(2); t.push_back(3); t.push_back(3); t.push_back(4); std::cout << majorElemet(t); }
run
|
edit
|
history
|
help
0
google
ArrAdSubMul
InverseMatrix2n2
find first non repeating
operator++
Kishan_template
BinomialPoisson
Segmented Sieve
ConversionOperator
MoaJhalMury