[iOS] Swift로 Counter 구현하기

someng·2022년 12월 11일
0

iOS

목록 보기
22/33

Counter 구현

var cnt = Dictionary( tangerine.map { ($0, 1) }, uniquingKeysWith: +)

Dictionary에서 max value 찾는법

let max = cnt.values.max()!

특정 value를 가진 Dictionary 필터링

let keys = cnt.filter { $0.value == max }

참고링크
https://daewonyoon.tistory.com/436

profile
👩🏻‍💻 iOS Developer

0개의 댓글