130. 주사위 게임 1
import Foundation func solution(_ a:Int, _ b:Int) -> Int { var answer : Int = 0 answer = a*b % 2 != 0 ? a*a + b*b : (a%2 == 0 && b%2 == 0) ? abs(a-b) : 2*(a+b) ...
import Foundation func solution(_ a:Int, _ b:Int) -> Int { var answer : Int = 0 answer = a*b % 2 != 0 ? a*a + b*b : (a%2 == 0 && b%2 == 0) ? abs(a-b) : 2*(a+b) ...
import Foundation func solution(_ str_list:[String], _ ex:String) -> String { var answer : String = "" answer = str_list.map{$0.contains(ex) ? "" : $0}.joined() r...
import Foundation func solution(_ my_string:String) -> [String] { var answer : [String] = [] answer = my_string.split(separator : " ").map{String($0)} return answer }...
import Foundation func solution(_ arr:[Int], _ n:Int) -> [Int] { var answer : [Int] = [] answer = arr.count % 2 != 0 ? arr.enumerated().map{$0.0%2 != 0 ? $0.1 : $0.1 + n} ...
import Foundation func solution(_ my_string:String, _ target:String) -> Int { var answer : Int = 0 answer = my_string.contains(target) ? 1:0 return answer } 12...
import Foundation func solution(_ num_list:[Int]) -> [Int] { var answer : [Int] = [] answer = Array(num_list.sorted()[5...]) return answer } 이전 문제 122번과 거의 같은 ...
import Foundation func solution(_ str1:String, _ str2:String) -> Int { var answer : Int = 0 answer = str2.contains(str1) ? 1 : 0 return answer } 배열과 같이 문자열 또한 ...
import Foundation func solution(_ num_list:[Int]) -> [Int] { var answer : [Int] = [] answer = Array(num_list.sorted()[0...4]) return answer } 배열의 인덱스로 하려고해서 [0…4]로 하여 Arr...
import Foundation func solution(_ arr:[Int], _ k:Int) -> [Int] { var answer : [Int] = [] answer = k%2 == 0 ? arr.map{$0 + k} : arr.map{$0 * k} return answer } ...