Skip to content

Instantly share code, notes, and snippets.

@amorfati0310
Created March 28, 2018 12:50
Show Gist options
  • Save amorfati0310/3aec61884eca646e2af6b575a9e52415 to your computer and use it in GitHub Desktop.
Save amorfati0310/3aec61884eca646e2af6b575a9e52415 to your computer and use it in GitHub Desktop.
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
const dicA = A.reduce((ac, c) => {
ac[c] = c
return ac;
}, {})
for (let i = 1; i <= A.length + 1; i++) {
if (dicA[i] !== i) return i;
}
}
@youngdo212
Copy link

8번째줄 if문을 if(!dicA[i])로만 해도 될거 같아요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment