Easy solution Using two Hashmaps.
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n1. Create two hashmaps 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Create two hashmaps to store the products of each pair of numbers in each array.\n2. Add the products in the hashmaps respectively.\n3. Using for loop check if the square of a number from nums1 is already present in the hashmap where it has the products of pairs of numbers from nums2. Increment the count variable if the hashmap result is greater than 0.\n4. Repeat the same with nums2 also.\n5. Return the count at the end.\n\n# Complexity\n- Time complexity:\n$$O(n^2)+O(m^2)$$\n\n- Space complexity:\n$$O(n)+O(m)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int numTriplets(vector<int>& nums1, vector<int>& nums2) {\n        unordered_map<long long int, int> mp1;\n        unordered_map<long long int, int> mp2;\n\n        // Calculate the product of each pair in nums1 and store in mp1\n        for (int i = 0; i < nums1.size(); i++) \n        {\n            for (int j = i + 1; j < nums1.size(); j++) \n            {\n                mp1[(long long)nums1[i] * nums1[j]]++;\n            }\n        }\n        // Calculate the product of each pair in nums2 and store in mp2\n        for (int i = 0; i < nums2.size(); i++) \n        {\n            for (int j = i + 1; j < nums2.size(); j++) \n            {\n                mp2[(long long)nums2[i] * nums2[j]]++;\n            }\n        }\n        int count = 0;\n        // Check if the product of numbers in nums2 is equal to square in nums1\n        for (int i = 0; i < nums1.size(); i++) \n        {\n            int x = mp2[(long long)nums1[i] * nums1[i]];\n            if (x > 0)\n                count += x;\n        }\n        // Check if the product of numbers in nums1 is equal to square in nums2\n        for (int i = 0; i < nums2.size(); i++) \n        {\n            int x = mp1[(long long)nums2[i] * nums2[i]];\n            if (x > 0)\n                count += x;\n        }\n        return count;\n    }\n};\n```
['C++']