import Foundation let MNH = readLine()!.split(separator: " ").map { Int($0)! } let M = MNH[0] // ์ด let N = MNH[1] // ํ let H = MNH[2] // ๋ฉด var board = [[[Int]]]() for _ in 0..
[Swift] ๋ฐฑ์ค 1926 ๊ทธ๋ฆผ
ยท
๐ ์ฝํ /BOJ
import Foundation let nm = readLine()!.components(separatedBy: " ").map { Int($0)! } let n = nm[0] let m = nm[1] var board = [[Int]]() for _ in 0..
ํ์ด ์์ฒญ ํฐ ์์ ํฉํ ๋ฆฌ์ผ์ ์ถ๋ ฅํ๋ ๋ฌธ์ ๋ค. ์๊ฐ ๋๋ฌด ํฌ๊ธฐ ๋๋ฌธ์ ์๋ฅผ ๋ฐฐ์ด๋ก ๋๋ ์ ํ์ด์ผํ๋ค. temp๋ผ๋ ์์๋ฐฐ์ด์ ์ญ์์ผ๋ก ์ํํ๋ฉด์ ํ์ฌ ์ซ์์ ์ด์ ๋จ๊ณ์์์ ๋๋จธ์ง๋ฅผ ๋ํ๋ค. ๊ทธ ์ดํฉ์ 10์ผ๋ก ๋๋ ๋ชซ์ด ์๋ก์ด ๋๋จธ์ง๊ฐ ๋๋ค. ์๋ก์ด ๋๋จธ์ง๋ฅผ ๋ฌธ์์ด๋ก ๋ณํํ์ฌ result ๋ฌธ์์ด์ ์์ชฝ์ ์ฝ์ ํ๋ค. ์ด๊ฒ์ ์ฌ๊ท๋ก ๋ฐ๋ณตํ์ฌ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํ๋ค. ์ฝ๋ func extraLongFactorials(n: Int) -> Void { // Write your code here var result = "1" for num in 1...n { result = multiply(result, by: num) } print(result) } func multiply(_ a: String, by: Int) ->..
[๊ตฌํ] Picking Numbers
ยท
๐ ์ฝํ /HackerRank
func pickingNumbers(a: [Int]) -> Int { // Write your code here let uniqueArr = Array(Set(a)) var arr = [Int]() var res = [Int]() var max = 0 for n in uniqueArr { for e in a { if n - e = 0 { arr.append(n-e) } } if arr.count > max { max = arr.count res = arr } arr = [] } return res.count }
[๊ตฌํ] Climbing the Leaderboard
ยท
๐ ์ฝํ /HackerRank
https://www.hackerrank.com/challenges/climbing-the-leaderboard/problem?isFullScreen=true Climbing the Leaderboard | HackerRank Help Alice track her progress toward the top of the leaderboard! www.hackerrank.com func climbingLeaderboard(ranked: [Int], player: [Int]) -> [Int] { var res = Array(repeating: 0, count: player.count) var uniqueRanked = [Int]() for score in ranked { if let lastScore = un..
import Foundation func solution(_ n:Int, _ build_frame:[[Int]]) -> [[Int]] { var answer = Set() func canConstruct() -> Bool { for structure in answer { let x = structure[0], y = structure[1], a = structure[2] // ๊ธฐ๋ฅ if a == 0 { if answer.contains([x - 1, y, 1]) || answer.contains([x, y, 1]) || answer.contains([x, y - 1, 0]) || y == 0 { continue } return false } // ๋ณด else { if answer.contains([x, ..
[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..
[Swift] ํ๋ก๊ทธ๋๋จธ์ค42862 ์ฒด์ก๋ณต
ยท
๐ ์ฝํ /ํ๋ก๊ทธ๋๋จธ์ค
import Foundation func solution(_ n:Int, _ lost:[Int], _ reserve:[Int]) -> Int { var lost = lost.sorted(by: