Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 면접을 위한 CS 전공 지식 노트 Tree
- coremotion
- 자료구조
- 강한 참조 순환
- 면접을 위한 CS전공 지식 노트
- CoreData
- CarouselCollectionview
- Reference Cycle
- UserDefaults
- SWIFT
- class struct
- TableView
- 테이블뷰 나누기
- @escaping
- Carousel CollectionView
- wil
- firebase
- tableview section별 다른 cell적용
- 프로그래머스
- retain cycle
- Input Output
- 양궁대회
- til
- UIKit
- Array vs Linked List
- NavigationSearchBar
- TableView Section
- 롤케이크 자르기
- ReferceCycle
- Value Type Reference Type
Archives
- Today
- Total
개발하는 동글 :]
[TIL],[프로그래머스],[롤케이크 자르기],[Swift] 본문
import Foundation
func solution(_ topping:[Int]) -> Int {
var array1:[Int:Int] = [:]
var array2:[Int:Int] = [:]
var count = 0
for i in topping{
if array1[i] == nil{
array1[i] = 1
} else {
array1[i]! += 1
}
}
for i in topping{
if array1[i]! == 1{
array1[i] = nil
} else {
array1[i]! -= 1
}
if array2[i] == nil{
array2[i] = 1
} else {
array2[i]! += 1
}
if array1.keys.count == array2.keys.count{ count += 1 }
}
return count
}