class Solution {
  public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param weightsA int整型vector
     * @param weightsB int整型vector
     * @return int整型
     */
    map<int, int>mp;
    map<int, int>::iterator it;
    int findMode(vector<int>& weightsA, vector<int>& weightsB) {
        // write code here
        int la = weightsA.size();
        int lb = weightsB.size();
        for (int i = 0; i < la; ++i)
            mp[weightsA[i]]++;
        for (int i = 0; i < lb; ++i)
            mp[weightsB[i]]++;
        int ans = 0, cnt = 0;
        for (it = mp.begin(); it != mp.end(); it++) {
            if (it->second >= ans) {
                ans = it->second;
                cnt = it->first;
            }
        }
        return cnt;
    }
};

一、题目考察的知识点

map计数

二、题目解答方法的文字分析

很久没写map了,导致都忘记怎么使用迭代器了,还好边查阅资料边回忆,边写边回忆,还是想起怎么写了。模板题,看过就会写

三、本题解析所用的编程语言

c++