[Swift] 백준 1927 최소 힙
·
📝 코테/BOJ
import Foundation struct Heap { private var elements = [T]() private let comparer: (T, T) -> Bool init(comparer: @escaping (T, T) -> Bool) { self.comparer = comparer } mutating func insert(element: T) { if elements.isEmpty { elements.append(element) elements.append(element) return } elements.append(element) // swim up swimUp(index: elements.count - 1) } mutating private func swimUp(index: Int) {..