<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> and an integer <code>pivot</code>. Rearrange <code>nums</code> such that the following conditions are satisfied:</p>
<ul>
<li>Every element less than <code>pivot</code> appears <strong>before</strong> every element greater than <code>pivot</code>.</li>
<li>Every element equal to <code>pivot</code> appears <strong>in between</strong> the elements less than and greater than <code>pivot</code>.</li>
<li>The <strong>relative order</strong> of the elements less than <code>pivot</code> and the elements greater than <code>pivot</code> is maintained.
<ul>
<li>More formally, consider every <code>p<sub>i</sub></code>, <code>p<sub>j</sub></code> where <code>p<sub>i</sub></code> is the new position of the <code>i<sup>th</sup></code> element and <code>p<sub>j</sub></code> is the new position of the <code>j<sup>th</sup></code> element. For elements less than <code>pivot</code>, if <code>i < j</code> and <code>nums[i] < pivot</code> and <code>nums[j] < pivot</code>, then <code>p<sub>i</sub>< p<sub>j</sub></code>. Similarly for elements greater than <code>pivot</code>, if <code>i < j</code> and <code>nums[i] > pivot</code> and <code>nums[j] > pivot</code>, then <code>p<sub>i</sub>< p<sub>j</sub></code>.</li>
</ul>
</li>
</ul>
<p>Return <code>nums</code><em> after the rearrangement.</em></p>