<p>You are given two <strong>0-indexed</strong> arrays <code>nums1</code> and <code>nums2</code> of length <code>n</code>, both of which are <strong>permutations</strong> of <code>[0, 1, ..., n - 1]</code>.</p>
<p>A <strong>good triplet</strong> is a set of <code>3</code><strong>distinct</strong> values which are present in <strong>increasing order</strong> by position both in <code>nums1</code> and <code>nums2</code>. In other words, if we consider <code>pos1<sub>v</sub></code> as the index of the value <code>v</code> in <code>nums1</code> and <code>pos2<sub>v</sub></code> as the index of the value <code>v</code> in <code>nums2</code>, then a good triplet will be a set <code>(x, y, z)</code> where <code>0 <= x, y, z <= n - 1</code>, such that <code>pos1<sub>x</sub>< pos1<sub>y</sub>< pos1<sub>z</sub></code> and <code>pos2<sub>x</sub>< pos2<sub>y</sub>< pos2<sub>z</sub></code>.</p>
<p>Return <em>the <strong>total number</strong> of good triplets</em>.</p>
There are 4 triplets (x,y,z) such that pos1<sub>x</sub>< pos1<sub>y</sub>< pos1<sub>z</sub>. They are (2,0,1), (2,0,3), (2,1,3), and (0,1,3).
Out of those triplets, only the triplet (0,1,3) satisfies pos2<sub>x</sub>< pos2<sub>y</sub>< pos2<sub>z</sub>. Hence, there is only 1 good triplet.