c++ solution O(n*m)  using hash_map
\n#define ll long long int\nclass Solution {\npublic:\n    int find(vector<int>nums1,vector<int>nums2)\n    {\n        unordered_map<ll,ll>mp;\n        for(int 
```\n#define ll long long int\nclass Solution {\npublic:\n    int find(vector<int>nums1,vector<int>nums2)\n    {\n        unordered_map<ll,ll>mp;\n        for(int i=0;i<nums2.size();i++)\n        {\n            for(int j=i+1;j<nums2.size();j++)\n            {\n                ll p=(long long)nums2[i]*nums2[j];\n                mp[p]++;\n            }\n        }\n        ll count=0;\n        for(int i=0;i<nums1.size();i++)\n        {\n            ll p=(long long)nums1[i]*nums1[i];\n            if(mp.find(p)!=mp.end())\n            {\n                count+=mp[p];\n            }\n        }\n        return count;\n    }\n    int numTriplets(vector<int>& nums1, vector<int>& nums2) \n    {\n        return find(nums1,nums2)+find(nums2,nums1);\n    }\n};\n```
[]