[Swift] 프로그래머스12911 다음 큰 숫자
·
📝 코테/프로그래머스
import Foundation func solution(_ n:Int) -> Int { var answer : Int = n + 1 while true { if n.nonzeroBitCount == answer.nonzeroBitCount { break; } answer += 1 } return answer } n.nonzeroBitcount : 비트에서 1의개수 세준다. import Foundation func solution(_ n:Int) -> Int { let countOne = countBinaryOne(n); for num in n+1...Int.max { if countBinaryOne(num) == countOne { return num; } } return n } func countBi..