nums1
to its index.nums2
based on the mapping from nums1
.nums2
array.
a. For each element, use the Fenwick Tree to find the count of elements smaller than the current element that have appeared so far.
b. Update the Fenwick Tree with the current element.
c. Use the count from step 4a to calculate the number of good triplets centered at the current element.