Skip to content

Latest commit

 

History

History
23 lines (19 loc) · 522 Bytes

undefined-2.md

File metadata and controls

23 lines (19 loc) · 522 Bytes

이어 붙인 수

런타임 에러가 나올수도 있습니다.

import Foundation

func solution(_ num_list:[Int]) -> Int {
    var oddNum: [Int] = []
    var evenNum: [Int] = []
    
    for i in num_list {
        if i % 2 == 0 {
            evenNum.append(i)
        } else if i % 2 == 1 {
            oddNum.append(i)
        }
    }
    var sum1 = evenNum.map { String($0) }.joined(separator: "")
    var sum2 = oddNum.map { String($0) }.joined(separator: "")
    return (Int(sum1)! + Int(sum2)!)
}