✅ C++ Solution in O(mn) complexity clearly explained with comments
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: ```O(mn)```\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: ```O(n) or O(m) depending on which is larger```\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int getTriplets(vector<int>& nums1, vector<int>& nums2) {\n        int sum = 0;\n\n        // Storing the count of each element in the array of which we\'re calculating the squares of\n        unordered_map<int, int> num_map;\n        for(auto i:nums1) num_map[i]++;\n\n        // Now, traversing through the second array\n        for(int i = 0; i < nums2.size(); i++) {\n            for(int j = i+1; j < nums2.size(); j++) {\n\n                // This should be the square of one of the numbers in the other array\n                long long product = (long)nums2[i] * nums2[j];\n\n                // If the product can have a perfect square root\n                if(ceil(sqrt(product)) == floor(sqrt(product))) {\n\n                    // This is going to be our target that we should try finding in the other array\n                    // And we\'ll use the map for it. If it\'s found, we\'ll add it\'s total occurence to the total sum\n                    long long int target = sqrt(product);\n                    if(num_map.find(target) != num_map.end()) sum += num_map[target];\n                }\n            }\n        }\n\n        // returning the sum\n        return sum;\n    }\n\n    int numTriplets(vector<int>& nums1, vector<int>& nums2) {\n        return getTriplets(nums1, nums2) + getTriplets(nums2, nums1);\n    }\n};\n```
['Array', 'Hash Table', 'C++']