[Swift] ํ๋ก๊ทธ๋๋จธ์ค LV.0 ์ง์๋ ์ซ์ด์
ํ๋ก๊ทธ๋๋จธ์ค LV.0 ๋ชจ์ ์ง์๋ ์ซ์ด์ ๋ฌธ์ ์ค๋ช
์ ์ n์ด ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง ๋, n ์ดํ์ ํ์๊ฐ ์ค๋ฆ์ฐจ์์ผ๋ก ๋ด๊ธด ๋ฐฐ์ด์ return ํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์. ์ ํ ์ฌํญ 1 ≤ n ≤ 100 ์
์ถ๋ ฅ ์ n result 10 [1, 3, 5, 7, 9] 15 [1, 3, 5, 7, 9, 11, 13, 15] ์
์ถ๋ ฅ ์ ์ค๋ช
์
์ถ๋ ฅ ์ #1 10 ์ดํ์ ํ์๊ฐ ๋ด๊ธด ๋ฐฐ์ด [1, 3, 5, 7, 9]๋ฅผ returnํฉ๋๋ค. ์
์ถ๋ ฅ ์ #2 15 ์ดํ์ ํ์๊ฐ ๋ด๊ธด ๋ฐฐ์ด [1, 3, 5, 7, 9, 11, 13, 15]๋ฅผ return ํฉ๋๋ค. ์ ์ถ import Foundation func solution(_ n:Int) -> [Int] { var answer = [Int]() for i..
2022. 11. 30.
[Swift] Codility Lesson 5 - CountDiv
๋ฌธ์ Write a function: public func solution(_ A : Int, _ B : Int, _ K : Int) -> Int that, given three integers A, B and K, returns the number of integers within the range [A..B] that are divisible by K, i.e.: { i : A ≤ i ≤ B, i mod K = 0 } For example, for A = 6, B = 11 and K = 2, your function should return 3, because there are three numbers divisible by 2 within the range [6..11], namely 6, 8 an..
2022. 7. 26.
[Swift] Codility Lesson 4 - MissingInteger
๋ฌธ์ This is a demo task. Write a function: public func solution(_ A : inout [Int]) -> Int that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5. Given A = [1, 2, 3], the function should return 4. Given A = [−1, −3], the function should return 1. Write an efficie..
2022. 7. 24.