삽질.....
-
문자열 나누기프로그래머스 2022. 12. 7. 20:16
class Solution { fun solution(s: String): Int { var answer: Int = 0 var tempMap = mutableMapOf() s.forEach{ if(tempMap.containsKey(it)){ val newValue = tempMap.get(it)!!.toInt()+1 tempMap.put(it,newValue) } else { tempMap.put(it,1) } val checkList = tempMap.values.toList() if(checkList.first() * 2 == checkList.sum()){ answer += 1 tempMap.clear() } } if(tempMap.isNotEmpty()){ answer += 1 } return..