C++ BRUTEFORCE
```\nclass Solution {\npublic:\n    #define ll long long int\n    int numTriplets(vector& a, vector& b) {\n        mapmp1;\n        mapmp2;\n        sort(a.begi
```\nclass Solution {\npublic:\n    #define ll long long int\n    int numTriplets(vector<int>& a, vector<int>& b) {\n        map<ll,ll>mp1;\n        map<ll,ll>mp2;\n        sort(a.begin(),a.end());\n        sort(b.begin(),b.end());\n        for(int i = 0 ; i < a.size();i++)\n        {\n            ll p = (ll)a[i]*a[i];\n            mp1[p]++;\n        }\n         for(int i = 0 ; i < b.size();i++)\n        {\n            ll p = (ll)b[i]*b[i];\n            mp2[p]++;\n        }\n    ll ans = 0  ;\n        for(int i = 0 ; i  < b.size();i++)\n        {\n            for(int j=i+1;j<b.size();j++){\n            ll p = (ll)b[i]*b[j];\n                ans+=mp1[p];\n                }\n        }\n        for(int i = 0 ; i  < a.size();i++)\n        {\n            for(int j=i+1;j<a.size();j++){\n            ll p = (ll)a[i]*a[j];\n                ans+=mp2[p];\n                }\n        }\n        return ans;\n    }\n};
[]