Skip to content

Commit

Permalink
:add (programmers level 1): js 풀이
Browse files Browse the repository at this point in the history
  • Loading branch information
padosum committed Nov 21, 2022
1 parent b1d1fbd commit 5f54b12
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
20 changes: 20 additions & 0 deletions programmers/level1/완주하지 못한 선수.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function solution(participant, completion) {
const map = new Map()
let result = ''

participant.forEach(player => {
map.set(player, (map.get(player) || 0) + 1)
})

completion.forEach(player => {
map.set(player, map.get(player) - 1)
})

for (const [key, value] of map.entries()) {
if (value === 1) {
result = key
}
}

return result
}
9 changes: 9 additions & 0 deletions programmers/level1/폰켓몬.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function solution(nums) {
const ponkemon = [...new Set(nums)]

if (nums.length / 2 < ponkemon.length) {
return nums.length / 2
} else {
return ponkemon.length
}
}

0 comments on commit 5f54b12

Please sign in to comment.