C++ using 2 unordered_map
\nclass Solution {\npublic:\n   int numTriplets(vector<int>& nums1, vector<int>& nums2) {\n        int n=nums1.size();\n        int m=nums2.size();\n        uno
```\nclass Solution {\npublic:\n   int numTriplets(vector<int>& nums1, vector<int>& nums2) {\n        int n=nums1.size();\n        int m=nums2.size();\n        unordered_map<long long int,long long int>s1;\n        unordered_map<long long int,long long int>s2;\n        int count=0;\n        for(int i=0;i<n;i++)\n            s1[(long long)nums1[i]*nums1[i]]++;\n        for(int i=0;i<m;i++)\n            s2[(long long) nums2[i]*nums2[i]]++;\n        \n     \n        \n        for(int i=0;i<m;i++){\n            for(int j=i+1;j<m;j++){\n                \n                if(s1.find((long long)nums2[i]*nums2[j])!=s1.end())\n                    \n                    count+=(s1[(long long)nums2[i]*nums2[j]]);\n                \n            }\n        }\n        for(int i=0;i<n;i++){\n            for(int j=i+1;j<n;j++){\n                if(s2.find((long long)nums1[i]*nums1[j])!=s2.end())count+=(s2[(long long)nums1[i]*nums1[j]]);\n                 \n            }\n            \n        }return count;\n   }\n};\n```
[]