js实现排列组合打印
问题描述:输入一个数字n,提供一个排列组合方法combination(n),输出所有排列的可能,比如:combination(2) -> [1, 2]、[2, 1]; combination(3) -> [1,2,3]、[1,3,2]、[2,1,3]、[2,3,1]、[3,1,2]、[3,2,1]
解决方法:
const combination = n => {
const aryNumber = Array.from({ length: n }).map((e, i) =&
原创
2022-01-04 14:31:05 ·
466 阅读 ·
0 评论