C++||Two Pointers||Easy to Understand
```\nclass Solution {\npublic:\n    int countTriplet(vector &nums1,vector &nums2)\n    {\n        int ans=0,left,right;\n        unordered_map freq;\n        fo
```\nclass Solution {\npublic:\n    int countTriplet(vector<int> &nums1,vector<int> &nums2)\n    {\n        int ans=0,left,right;\n        unordered_map<int,int> freq;\n        for(auto &n:nums2)\n        {\n            freq[n]++;\n        }\n        for(int i=0;i<nums1.size();i++)\n        {\n            long long t=(long long)nums1[i]*nums1[i];\n            left=0;\n            right=nums2.size()-1;\n            while(left<right)\n            {\n                long long temp=(long long)nums2[left]*nums2[right];\n                if(t==temp)\n                {\n                    if(nums2[left]==nums2[right])\n                    {\n                        ans+=(freq[nums2[left]]*(freq[nums2[left]]-1))/2;\n                            break;\n                    }\n                    ans+=freq[nums2[left]]*freq[nums2[right]];\n                    left+=freq[nums2[left]];\n                    right-=freq[nums2[right]];\n                }\n                else if(t>temp)\n                {\n                    left+=freq[nums2[left]];\n                }\n                else\n                {\n                    right-=freq[nums2[right]];\n                }\n            }\n        }\n        return ans;\n    }\n    int numTriplets(vector<int>& nums1, vector<int>& nums2)\n    {\n        sort(nums1.begin(),nums1.end());\n        sort(nums2.begin(),nums2.end());\n        return countTriplet(nums1,nums2)+countTriplet(nums2,nums1);\n        \n    }\n};\n//if you like the solution plz upvote.
['Two Pointers', 'C']