count the frequency of every product formed | easy to understand
Code\n\nclass Solution {\npublic:\n    int numTriplets(vector<int>& nums1, vector<int>& nums2) \n    {\n       int type1 = 0;\n       unordered_map<long long in
# Code\n```\nclass Solution {\npublic:\n    int numTriplets(vector<int>& nums1, vector<int>& nums2) \n    {\n       int type1 = 0;\n       unordered_map<long long int,int>mp;\n       for(int i = 0 ; i < nums1.size() ; i++) mp[1LL * nums1[i]*nums1[i]]++;\n       for(int j = 0 ; j < nums2.size() ; j++)\n       {\n           for(int k = j+1 ; k < nums2.size() ; k++)\n           {\n               long long int product = (1LL*nums2[j]*nums2[k]);\n               if(mp.find(product) != mp.end()) type1+=mp[product];\n           }\n       }    \n      \n       mp.clear();\n       int type2 = 0;\n       for(int i = 0 ; i < nums2.size() ; i++) mp[1LL * nums2[i]*nums2[i]]++;\n       for(int j = 0 ; j < nums1.size() ; j++)\n       {\n           for(int k = (j+1) ; k < nums1.size() ; k++)\n           {\n               long long int product = (1LL * nums1[j]*nums1[k]);\n               if(mp.find(product) != mp.end()) type2+=mp[product];\n           }\n       }\n       return (type1 + type2);\n    }\n};\n```
['Array', 'Hash Table', 'Math', 'Two Pointers', 'C++']