Created
July 25, 2018 09:46
-
-
Save uinz/4580d4959f41716cc2b44ea37c1d10ee to your computer and use it in GitHub Desktop.
实现0和1的排列组合
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getArr(size: number) { | |
const result: number[][] = []; | |
(function loop(arr: number[] = []) { | |
if (arr.length < size) { | |
loop([...arr, 0]); | |
loop([...arr, 1]); | |
} else { | |
result.push(arr); | |
} | |
})(); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment