<p>An array is <strong>monotonic</strong> if it is either monotone increasing or monotone decreasing.</p>
<p>An array <code>nums</code> is monotone increasing if for all <code>i <= j</code>, <code>nums[i] <= nums[j]</code>. An array <code>nums</code> is monotone decreasing if for all <code>i <= j</code>, <code>nums[i] >= nums[j]</code>.</p>
<p>Given an integer array <code>nums</code>, return <code>true</code><em> if the given array is monotonic, or </em><code>false</code><em> otherwise</em>.</p>