BOJ-15649
![[백준] BOJ-15649 N과 M (1)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FKTNmH%2FbtrSqXX0l7B%2FAAAAAAAAAAAAAAAAAAAAADWOfISbRQOn6o2Qe30VyYVva6UoLInkwSFuvZtdLtu4%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DnFF4pmD6i%252Btlh%252B0hgn5H%252FkNjbok%253D)
[백준] BOJ-15649 N과 M (1)
문제 N과 M을 입력받아 nPm 의 순열을 구하는 문제였다. 풀이 import Foundation let nm = readLine()!.split(separator: " ").map { Int($0)! } let n = nm.first! let m = nm.last! let nums = Array(1...n) // [1, 2, ..., n] /// nPr func permutation(n elements: [Int], r: Int) -> [[Int]] { var result = [[Int]]() var visited = [Bool](repeating: false, count: n) func permu(_ temp: [Int]) { if temp.count == r { result.append(temp) ..