Solution Number of Ways Where Square of Number Is Equal to Product of Two Numbers
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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public function numTriplets($nums1, $nums2) {\n        $mp1 = [];\n        $mp2 = [];\n\n        for ($i = 0; $i < count($nums1); $i++) {\n            for ($j = $i + 1; $j < count($nums1); $j++) {\n                $product = (int)$nums1[$i] * (int)$nums1[$j];\n                if (!isset($mp1[$product])) {\n                    $mp1[$product] = 0;\n                }\n                $mp1[$product]++;\n            }\n        }\n\n        for ($i = 0; $i < count($nums2); $i++) {\n            for ($j = $i + 1; $j < count($nums2); $j++) {\n                $product = (int)$nums2[$i] * (int)$nums2[$j];\n                if (!isset($mp2[$product])) {\n                    $mp2[$product] = 0;\n                }\n                $mp2[$product]++;\n            }\n        }\n\n        $count = 0;\n\n        foreach ($nums1 as $num) {\n            $square = (int)$num * (int)$num;\n            if (isset($mp2[$square])) {\n                $count += $mp2[$square];\n            }\n        }\n\n        foreach ($nums2 as $num) {\n            $square = (int)$num * (int)$num;\n            if (isset($mp1[$square])) {\n                $count += $mp1[$square];\n            }\n        }\n\n        return $count;\n    }\n}\n\n```
['PHP']