프로그래머스 - 영어 끝말잇기
·
Algorithm/programmers
import Foundationfunc solution(_ n:Int, _ words:[String]) -> [Int] { var stack: [String] = [] var previous: Character = words.first!.last! var num = 1 var cycle = 1 for word in words { if num > n { num = 1 cycle += 1 } if stack.isEmpty { stack.append(word) } else { if stack.contains(word) |..