-
728x90
class Solution { fun solution(s: String): IntArray { var answer = intArrayOf() val tempString = s.replace("{","").replace("}","") val tempList = tempString.split(",") val tempSet = tempList.toSet() var tempMap = mutableMapOf<Int,Int>() for(temp in tempSet){ tempMap.put(tempList.count{e-> e == temp},temp.toInt()) } for(i in tempMap.size downTo 1){ answer += tempMap.get(i)!! } return answer } }
저의 현재 실력으로 푼 문제 답안이며, 가장 좋은 코드는 아닐 수 있으며, 코틀린을 공부하면서 추가적으로 알게 된 개념이 있어 다시 풀 경우 추가적으로 코드를 작성 할 수 있도록 하겠습니다.
'프로그래머스' 카테고리의 다른 글
[프로그래머스][2022 KAKAO BLIND RECRUITMENT][Kotlin]주차 요금 계산 (1) 2022.09.26 k진수에서 소수 개수 구하기 (1) 2022.09.26 [프로그래머스][Kotlin]괄호 회전하기 (0) 2022.09.26 행렬의 곱셈 (0) 2022.09.26 멀리 뛰기 (0) 2022.09.26