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 <= 1, n - e >= 0 {
arr.append(n-e)
}
}
if arr.count > max {
max = arr.count
res = arr
}
arr = []
}
return res.count
}
๋ฐ์ํ
'๐ ์ฝํ > HackerRank' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๊ตฌํ] Extra Long Factorials (0) | 2023.05.17 |
---|---|
[๊ตฌํ] Climbing the Leaderboard (0) | 2023.05.15 |