[구현] 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..
[Swift] 프로그래머스60061 기둥과 보 설치
·
📝 코테/프로그래머스
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, ..
JerryiOS
Jerry