C++|| O(MN)||Easiest solution with self explanatory code
Please Note that time complexity of find function in unordered_map is O(1)\n\nclass Solution {\npublic:\n    int numTriplets(vector<int>& n1, vector<int>& n2) {
Please Note that time complexity of find function in unordered_map is O(1)\n```\nclass Solution {\npublic:\n    int numTriplets(vector<int>& n1, vector<int>& n2) {\n        int n=n1.size();int m=n2.size();\n        long ans=0;\n        //type 1\n        for(int i=0;i<n;i++)\n        {\n            double a=n1[i];\n            unordered_map<double,int> s;\n            for(int j=0;j<m;j++)\n            {\n                double b=n2[j];\n                double f=a*a/b;\n                if(s.find(f)!=s.end()) ans+=s[f];\n                s[b]++;\n            }\n        }\n        //type 2\n        for(int i=0;i<m;i++)\n        {\n            double a=n2[i];\n            unordered_map<double,int> s;\n            for(int j=0;j<n;j++)\n            {\n                double b=n1[j];\n                double f=a*a/b;\n                if(s.find(f)!=s.end()) ans+=s[f];\n                s[b]++;\n            }\n        }\n        return ans;\n    }\n};\n```
[]