Files
freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/combinations.chinese.md
2020-08-16 04:45:18 +05:30

1.8 KiB
Raw Blame History

title, id, challengeType, videoUrl, localeTitle
title id challengeType videoUrl localeTitle
Combinations 5958469238c0d8d2632f46db 5 组合

Description

任务:

给定非负整数m和n 以排序顺序生成从0 到n-1的整数的所有大小m个 组合 (每个组合被排序并且整个表被排序)。

例:

3梳子5是

 0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4

Instructions

Tests

tests:
  - text: <code>combinations</code>是一种功能。
    testString: assert(typeof combinations === 'function');
  - text: '<code>combinations(3, 5)</code>应返回<code>[[0, 1, 2], [0, 1, 3], [0, 1, 4], [0, 2, 3], [0, 2, 4], [0, 3, 4], [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]</code> 。'
    testString: assert.deepEqual(combinations(testInput1[0], testInput1[1]), testOutput1);
  - text: '<code>combinations(4, 6)</code>应返回<code>[[0,1,2,3], [0,1,2,4], [0,1,2,5], [0,1,3,4], [0,1,3,5], [0,1,4,5], [0,2,3,4], [0,2,3,5], [0,2,4,5], [0,3,4,5], [1,2,3,4], [1,2,3,5], [1,2,4,5], [1,3,4,5], [2,3,4,5]]</code>'
    testString: assert.deepEqual(combinations(testInput2[0], testInput2[1]), testOutput2);

Challenge Seed

function combinations (m, n) {
  // Good luck!
  return true;
}

After Test

console.info('after the test');

Solution

// solution required