[C++] Explanation, Approach and Code and Time Complexity
Approach\n    0. Sort the arrays since you need to search\n    For type 1:\n\t\n    1. select first number from nums1\n    2. Square it\n    3. Select number fr
Approach\n    0. Sort the arrays since you need to search\n    For type 1:\n\t\n    1. select first number from nums1\n    2. Square it\n    3. Select number from nums2 and divide it by square of nums1[i]\n    4. If divisible, search for all occurences of the other pair in nums2\n    5. Lets there be x occurences then add x to ans.\n    6. But the intresting thing to note is if the numbers selected in nums2 is square root of \n    number selected in nums1 then we have one extra occurence, so subtract one from answer.\n    \nRepeat this for type 2.\nFinally return answer.\n\nSince we sort the array use upper_bound and lower_bound to search in log(n);\n\nOverall time Complexity =mlog(n)+nlog(m)\nwhich is overall nlog(n)\n\n```\nclass Solution\n{\npublic:\n    int count(vector<int> &arr, long long int x, int n)\n    {\n\n        auto low = lower_bound(arr.begin(), arr.end(), x);\n        if (low == arr.end() || *low != x)\n            return 0;\n        auto high = upper_bound(low, arr.end(), x);\n        return high - low;\n    }\n\n    int numTriplets(vector<int> &nums1, vector<int> &nums2)\n    {\n        int m = nums1.size();\n        int n = nums2.size();\n        int i, j;\n        sort(nums1.begin(), nums1.end());\n        sort(nums2.begin(), nums2.end());\n        int trip = 0;\n        for (i = 0; i < m; i++)\n        {\n            long long toSearch = (long long)nums1[i] * (long long)nums1[i];\n            for (j = 0; j < n; j++)\n            {\n                long long int num1 = nums2[j];\n                if (toSearch % num1 == 0)\n                {\n\n                    int c = count(nums2, toSearch / num1, n);\n                    if (c > 0)\n                        trip += c;\n                    if (num1 * num1 == toSearch)\n                        trip -= 1;\n                }\n            }\n        }\n        for (i = 0; i < n; i++)\n        {\n            long long toSearch = (long long)nums2[i] * (long long)nums2[i];\n            for (j = 0; j < m; j++)\n            {\n                long long int num1 = nums1[j];\n                if (toSearch % num1 == 0)\n                {\n\n                    int c = count(nums1, toSearch / num1, m);\n                    if (c > 0)\n                        trip += c;\n                    if (num1 * num1 == toSearch)\n                        trip -= 1;\n                }\n            }\n        }\n        return trip / 2;\n    }\n};
['C', 'Binary Tree']