import Foundation // // LeetCode.swift // m323 // // Created by cediackermann on 18.05.2026. // class LeetCode { func hammingWeight(_ n: Int) -> Int { var weight = 0 let quotient = n / 2 weight += n % 2 let roundedQuotient = floor(Double(quotient)) if roundedQuotient != 0 { weight += hammingWeight(Int(roundedQuotient)) } return weight } func singleNumber(_ nums: [Int]) -> Int { var result = 0 for num in nums { result ^= num } return result } func containsDuplicate(_ nums: [Int]) -> Bool { return nums.count != Set(nums).count } func sortedSquares(_ nums: [Int]) -> [Int] { return nums.map { $0 * $0 }.sorted() } func productExceptSelf(_ nums: [Int]) -> [Int] { var result = [Int](repeating: 1, count: nums.count) var prefix = [Int](repeating: 1, count: nums.count) var suffix = [Int](repeating: 1, count: nums.count) var runningProduct = 1 for i in 0..