2
* 1. compute all positions for each number3
* 2. filter arrays of max length4
* 3. select minimum difference between its first and last elems6
var findShortestSubArray = function (nums) {7
const numPositions = {};8
for (let i = 0; i < nums.length; i++) {10
if (numPositions[num] == null) numPositions[num] = [];11
numPositions[num].push(i);15
// will store the positions of most frequent numbers17
for (const positions of Object.values(numPositions)) {18
const curLen = positions.length;19
if (curLen === maxLen) {20
maxPos.push(positions);21
} else if (curLen > maxLen) {27
let minDist = Number.MAX_SAFE_INTEGER;28
for (const positions of maxPos) {31
positions[positions.length - 1] - positions[0] + 1