Swift - 순열(Permutation)
1,2,3,4,5,6,7,8,9 중에서 중복되지 않고 3개를 뽑는 모든 경우의 수를 만들어라 예를들어 [1,2,3] [1,2,4] ... [9,8,7] 코드 import Foundation func permutation(_ arr : [Int],_ output : [Int],_ visited : [Bool],_ depth : Int,_ n : Int,_ r : Int){ var arr = arr var output = output var visited = visited if depth == r { // stack.append(output) print(output) return } for i in 0..
2020. 7. 11.
💯 Daily LeetCode Challenge Day_04 - Ugly Number II
Account Login - 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 문제 Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example: Input: n = 10 Output: 12 Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence..
2020. 7. 6.
Swift 배열 처리
String 과 Int 를 넘나드는 데이터 타입 변경 배열 반대로 순회 배열을 String으로 리턴 코드 import Foundation var arr1 : [Int] = [3,2,3,1,2,8,6,4,3,5,2,3,2,1] var arr2 : [Int] = [9,7,5,4,3,4,2,1,3,5,0,5,4,3] var answer : [Int] = [] var carry = 0 for i in (0..
2020. 7. 4.