Rust || Simple solution
Complexity\n- Time complexity: O(n^2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n^2)\n Add your space complexity here, e.g. O(n) \n\n
# Complexity\n- Time complexity: $$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n^2)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nuse std::collections::HashMap;\nimpl Solution {\n    pub fn num_triplets(nums1: Vec<i32>, nums2: Vec<i32>) -> i32 {\n        let nums1 = nums1.iter().map(|&n| n as i64).collect::<Vec<_>>();\n        let nums2 = nums2.iter().map(|&n| n as i64).collect::<Vec<_>>();\n        let mut products = HashMap::new();\n        for j in 0..nums1.len() {\n            for k in j+1..nums1.len() {\n                *products.entry(nums1[j]*nums1[k]).or_insert(0) += 1;\n            }\n        }\n        let mut ans = 0;\n        for &n in nums2.iter() {\n            ans += *products.get(&(n*n)).unwrap_or(&0);\n        }\n        products.clear();\n        for j in 0..nums2.len() {\n            for k in j+1..nums2.len() {\n                *products.entry(nums2[j]*nums2[k]).or_insert(0) += 1;\n            }\n        }\n        for &n in nums1.iter() {\n            ans += *products.get(&(n*n)).unwrap_or(&0);\n        }\n        ans\n    }\n}\n```
['Rust']