<p>Given two arrays of integers <code>nums1</code> and <code>nums2</code>, return the number of triplets formed (type 1 and type 2) under the following rules:</p>
<ul>
<li>Type 1: Triplet (i, j, k) if <code>nums1[i]<sup>2</sup> == nums2[j] * nums2[k]</code> where <code>0 <= i < nums1.length</code> and <code>0 <= j < k < nums2.length</code>.</li>
<li>Type 2: Triplet (i, j, k) if <code>nums2[i]<sup>2</sup> == nums1[j] * nums1[k]</code> where <code>0 <= i < nums2.length</code> and <code>0 <= j < k < nums1.length</code>.</li>