Sparse Arrays

  • + 0 comments

    A simple solution for C++: vector matchingStrings(vector strings, vector queries) { unordered_map strMp; vector ans; for (string s: strings) strMp[s]++; for (string s: queries) ans.push_back(strMp[s]); return ans;

    }