[프로그래머스] 외계어 사전

Sdoubleu·2023년 5월 8일
0

프로그래머스

목록 보기
27/34
post-thumbnail

문제


내가 쓴 풀이

class Solution {
    fun solution(spell: Array<String>, dic: Array<String>): Int {
        if(true in dic.map { spell.sorted().joinToString("") in
        it.toList().sorted().joinToString("") }) return 1 else return 2
    }
}

map 안에 조건식을
spell의 array가 dic 요소마다 정렬 후 in 을 사용해서 안에 있으면
true를 반환하게 하고 없다면 false를 반환시켜서
true가 하나라도 있다면 1을 return 시켰다

profile
개발자희망자

0개의 댓글