C+ (A very simple Two Sum like approach)
\n//Approach-1 (Simple solution)\nclass Solution {\npublic:\n    void twoProduct(ull target, vector<int> & nums, int &count) {\n        unordered_map<int, int> 
```\n//Approach-1 (Simple solution)\nclass Solution {\npublic:\n    void twoProduct(ull target, vector<int> & nums, int &count) {\n        unordered_map<int, int> mp;\n        mp[1] = 0;\n        for(int i = 0; i<nums.size(); i++) {\n            if(target%nums[i] == 0) {\n                int remain= target/nums[i];\n                count += mp[remain];\n            }\n            mp[nums[i]]++;\n        }\n    }\n\n    int numTriplets(vector<int>& nums1, vector<int>& nums2) {\n        int n1 = nums1.size();\n        int n2 = nums2.size();\n        \n        int count = 0;\n        for(int i = 0; i<n1; i++) {\n            twoProduct((long)nums1[i]*nums1[i], nums2, count);\n        }\n        \n        for(int i = 0; i<n2; i++) {\n            twoProduct((long)nums2[i]*nums2[i], nums1, count);\n        }\n        \n        return count;\n    }\n};\n```\n\n```\n//Approach-2 (Using C++ STL for a concise code)\n//However the concept of both solution are exactly same.\n//This approach just teaces on how to use STL in C++ to make life easy\n\nclass Solution {\npublic:\n    int twoProduct(long target, vector<int> &nums) {\n        unordered_map<int, int> mp;\n        int count = 0;\n        \n        for(int &x : nums) {\n            if(target%x == 0) {\n                count += mp[target/x];\n            }\n            mp[x]++;\n        }\n        return count;\n    }\n\n    int numTriplets(vector<int>& nums1, vector<int>& nums2) {\n        auto lambda1 = [&](int s, long n) {\n            return s + twoProduct(n*n, nums2);\n        };\n\n        auto lambda2 = [&](int s, long n) {\n            return s + twoProduct(n*n, nums1);\n        };\n\n        return accumulate(begin(nums1), end(nums1), 0, lambda1) +\n               accumulate(begin(nums2), end(nums2), 0, lambda2);\n    }\n};\n```
[]