순열
-
Swift combination, permutation 구현알고리즘/알고리즘 이론 2021. 12. 6. 17:42
다른 이의 글을 이해하고 내가 보기위해 쓰는 포스트! 알고리즘 문제를 풀 때, 순열 조합은 직접 구현해야한다. 참조된 포스트에서 Algorithms라는 Library를 제공한다. 하지만, 이는 개인의 Problem Solving 능력, 여타 시험에 기여하지 않으므로, 기본적인 알고리즘은 공부하자! 참고하여 구현해 본 Combination 더보기 func combination(_ target: [String], _ limit: Int, _ history: [String], _ visited: [Bool]) -> [[String]] { var sol = [[String]]() var tempVisited = visited if history.count >= limit { print(history, visit..
-
순열_LeetCode_permutation-in-string알고리즘/알고리즘 문제풀이 2021. 9. 8. 17:52
https://leetcode.com/problems/permutation-in-string/submissions/ Permutation in String - 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 문제 접근 1. s1의 순열을 Set으로 준비. 2. 준비된 Set의 element가 s2에 포함되었는지 확인. 실패 코드 실패 사유 : Time Limit Exceeded 개선 방법 : 순열 코드의 개선? 더보기 class Solution { func che..