알고리즘/알고리즘 문제 복기

LeetCode - 46. Permutation

내일도무사히 2021. 3. 29. 08:32

leetcode.com/problems/permutations/

 

Permutations - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

Answer

 

이번에도 백트레킹 문제

Permutation의 조합을 전부 구하는 문제였다.

used로 이미 사용한 수를 체크하여 백트래킹 시켜 풀어냈다.

 

아니면 다음과 같이 현재 남은 수를 체킹하여 풀어낼 수도 있다.

 

 


Reference

 

www.youtube.com/watch?v=idmgLLNIC2U

www.youtube.com/watch?v=KukNnoN-SoY