279. 중복순열 DFS

아현·2021년 8월 22일
0

Algorithm

목록 보기
292/400

출처





const solution = (N, M) => {
	const temp = Array.from({ length: M }, () => 0);
	const answer = [];
	const DFS = L => {
		if (L === M) {
			answer.push([...temp]);
		} else {
			for (let i = 1; i <= N; i++) {
				temp[L] = i;
				DFS(L + 1);
			}
		}
	};

	DFS(0);
  	return answer;
};

profile
Studying Computer Science

0개의 댓글