새소식

인기 검색어

프로그래머스/Lv.0

[Swift] 외계어 사전

  • -
import Foundation

func solution(_ spell:[String], _ dic:[String]) -> Int {
    dic.map { String($0.sorted()) }.contains(spell.sorted().joined()) ? 1 : 2
}

solution(["s", "o", "m", "d"], ["moos", "dzx", "smm", "sunmmo", "som"])

'프로그래머스 > Lv.0' 카테고리의 다른 글

[Swift] 유한소수 판별하기  (0) 2023.01.05
[Swift] 외계행성의 나이  (0) 2023.01.05
[Swift] 옹알이 (1)  (0) 2023.01.05
[Swift] 옷가게 할인 받기  (0) 2023.01.05
[Swift] 영어가 싫어요  (0) 2022.12.26
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.