분류 전체보기
-
import Foundation func solution(_ a:[Int], _ b:[Int]) -> Int { return zip(a, b).map{ $0 * $1 }.reduce(0, +) }
[Swift] 내적import Foundation func solution(_ a:[Int], _ b:[Int]) -> Int { return zip(a, b).map{ $0 * $1 }.reduce(0, +) }
2023.02.12 -
import Foundation func solution(_ n:Int) -> Int { var result = n-1 for i in 2..
[Swift] 나머지가 1이 되는 수 찾기import Foundation func solution(_ n:Int) -> Int { var result = n-1 for i in 2..
2023.02.12 -
import Foundation func solution(_ arr:[Int], _ divisor:Int) -> [Int] { let result = arr.sorted().filter{ $0 % divisor == 0} return result.count == 0 ? [-1] : result }
[Swift] 나누어 떨어지는 숫자 배열import Foundation func solution(_ arr:[Int], _ divisor:Int) -> [Int] { let result = arr.sorted().filter{ $0 % divisor == 0} return result.count == 0 ? [-1] : result }
2023.02.12 -
import Foundation func solution(_ number:Int, _ limit:Int, _ power:Int) -> Int { var attack = [Int](repeating: 0, count: number+1) for i in 1...number { var c = i while c limit ? power : $0 } return attack.reduce(0, +) }
[Swift] 기사단원의 무기import Foundation func solution(_ number:Int, _ limit:Int, _ power:Int) -> Int { var attack = [Int](repeating: 0, count: number+1) for i in 1...number { var c = i while c limit ? power : $0 } return attack.reduce(0, +) }
2023.02.12 -
import Foundation func solution(_ k:Int, _ m:Int, _ score:[Int]) -> Int { var answer = 0 var score = score.sorted{$0 > $1} var start = m-1 while start < score.count { answer += m*score[start] start += m } return answer }
[Swift] 과일 장수import Foundation func solution(_ k:Int, _ m:Int, _ score:[Int]) -> Int { var answer = 0 var score = score.sorted{$0 > $1} var start = m-1 while start < score.count { answer += m*score[start] start += m } return answer }
2023.02.12 -
import Foundation func solution(_ today:String, _ terms:[String], _ privacies:[String]) -> [Int] { var term = [String: Int]() // tems의 기간 계산 terms.forEach { let t = $0.components(separatedBy: " ") term[t[0]] = Int(t[1])! } return privacies.map { // 수집된 날짜와 타입 분할 let t = $0.components(separatedBy: " ") // 날짜 나누기 var result = t[0].components(separatedBy: ".").map { Int($0)! } // 유효날짜는 수집된날짜로부터 -1 ..
[Swift] 개인정보 수집 유효기간import Foundation func solution(_ today:String, _ terms:[String], _ privacies:[String]) -> [Int] { var term = [String: Int]() // tems의 기간 계산 terms.forEach { let t = $0.components(separatedBy: " ") term[t[0]] = Int(t[1])! } return privacies.map { // 수집된 날짜와 타입 분할 let t = $0.components(separatedBy: " ") // 날짜 나누기 var result = t[0].components(separatedBy: ".").map { Int($0)! } // 유효날짜는 수집된날짜로부터 -1 ..
2023.02.12 -
import Foundation func solution(_ s: String) -> [Int] { return s.enumerated().map { (i, c) in i - (Array(s)[0..
[Swift] 가장 가까운 같은 글자import Foundation func solution(_ s: String) -> [Int] { return s.enumerated().map { (i, c) in i - (Array(s)[0..
2023.02.12 -
func solution(_ s:String) -> String { return String(s[String.Index(encodedOffset: (s.count-1)/2)...String.Index(encodedOffset: s.count/2)]) }
[Swift] 가운데 글자 가져오기func solution(_ s:String) -> String { return String(s[String.Index(encodedOffset: (s.count-1)/2)...String.Index(encodedOffset: s.count/2)]) }
2023.02.12