We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include <string> #include <vector> #include <unordered_map> using namespace std; int solution(vector<int> array) { unordered_map<int, int> freq_map; for (int num : array) { freq_map[num]++; } int max_freq = 0; int mode = -1; bool is_unique = true; for (const auto& pair : freq_map) { if (pair.second > max_freq) { max_freq = pair.second; mode = pair.first; is_unique = true; } else if (pair.second == max_freq) { is_unique = false; } } return is_unique ? mode : -1; }
The text was updated successfully, but these errors were encountered:
fkdl0048
No branches or pull requests
The text was updated successfully, but these errors were encountered: