2020-10-06 23:10:08 +05:30

1.4 KiB

id, challengeType, videoUrl, localeTitle
id challengeType videoUrl localeTitle
594d8d0ab97724821379b1e6 5 平均值模式

Description

编写程序以查找集合的模式值。

可以忽略集合为空的情况。必须小心处理模式不唯一的情况。

如果不适合或不可能支持常规集合,请尽可能使用向量(数组)。如果不适合或不可能支持未指定的值类型,请使用整数。

Instructions

Tests

tests:
  - text: <code>mode</code>是一种功能。
    testString: assert(typeof mode === 'function');
  - text: '<code>mode([1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17])</code>应该相等<code>[6]</code>'
    testString: assert.deepEqual(mode(arr1), [6]);
  - text: '<code>mode([1, 2, 4, 4, 1])</code>应该等于<code>[1, 4]</code> 。'
    testString: assert.deepEqual(mode(arr2).sort(), [1, 4]);

Challenge Seed

function mode (arr) {
  // Good luck!
  return true;
}

After Test

console.info('after the test');

Solution

// solution required

/section>