惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy International News Feed
I
Intezer
T
Tenable Blog
S
Schneier on Security
Project Zero
Project Zero
G
GRAHAM CLULEY
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
Know Your Adversary
Know Your Adversary
博客园 - 司徒正美
The Cloudflare Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
News and Events Feed by Topic
博客园 - 叶小钗
宝玉的分享
宝玉的分享
L
LINUX DO - 热门话题
aimingoo的专栏
aimingoo的专栏
S
Secure Thoughts
Forbes - Security
Forbes - Security
T
The Exploit Database - CXSecurity.com
D
Darknet – Hacking Tools, Hacker News & Cyber Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 【当耐特】
罗磊的独立博客
IT之家
IT之家
H
Hacker News: Front Page
I
InfoQ
云风的 BLOG
云风的 BLOG
S
Security Affairs
M
MIT News - Artificial intelligence
GbyAI
GbyAI
Jina AI
Jina AI
Help Net Security
Help Net Security
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
Webroot Blog
Webroot Blog
L
Lohrmann on Cybersecurity
A
About on SuperTechFans
Attack and Defense Labs
Attack and Defense Labs
The Register - Security
The Register - Security
V
V2EX
G
Google Developers Blog
D
DataBreaches.Net
Apple Machine Learning Research
Apple Machine Learning Research
C
Cybersecurity and Infrastructure Security Agency CISA
J
Java Code Geeks
W
WeLiveSecurity
Cloudbric
Cloudbric
T
Tor Project blog

The Tracks of mulder21c

고정된 참조 위치 정보 선형 이미지의 최소 명도 대비 요구사항은 몇 대~ 몇? 단일 문자 단축키 (Character Key Shortcuts) 입력 방식(Input Modalities) 적응성(Adaptable) KWCAG 2.2 변경 사항 개요 Git hook으로 브랜치 이름 규칙 강제하기 댓글 시스템 remark42로 변경기 새 테마로 갈아입힘 Atomic Design + Storybook 적용 후기 json-server에 사용자 인증 구현하기 개발환경 WSL2 + zsh로 갈아타기 Pass function as props in vue 2020년 회고 colum flexbox에서 padding bottom 문제 해결 Nuxt를 통해 보는 프론트엔드 개발자가 하는 일 Nuxt Router kebab-case 처리 JS to SCSS 변환 Nuxt + Storybook 통합 하기 2020 이직 이야기 2020 이직 이야기 2020 이직 이야기 2020 이직 이야기 Windows에서 PM2 실행 오류 해결 오픈톡 정지에 대한 카카오톡 고객센터 후기 배려에 대한 단상 학습이 잘 되지 않는 이유 웹팩 4 마이그레이션 삽질기 babel 7 업데이트 후 node_modules 패키지가 변환되지 않는다면? white space는 4px이다? 정말? 2020년 시간 관리를 위해서 도입 한 툴들 Codility Lesson 5 — PassingCars 2019년 회고 Codility Lesson 4 — MaxCounters Codility Lesson 4 — FrogRiverOne Codility Lesson — PermCheck 착각은 자유가 아닌각 세미나 진행 후기 Codility Lesson 3 — tapeEquilibrium Codility Lesson 3 — PermMissingElm Codility Lesson 3 — FrogJump 알고리즘 연습을 다시 시작했다. Codility Lesson 2 — CyclicRotation Codility Lesson 2 — OddOccurrencesInArray Codility Lesson 1 — BinaryGap 아이패드 구매 하고 3주 써 본 기록 세미나 어떻게 준비해야 할까? HTML은 웹이다 접근성 향상을 위한 이름 짓기 접근성 교육에서 자주 나오는 상위 5가지 질문
Codility Lesson 4 — MissingInteger
멀더끙 · 2019-12-15 · via The Tracks of mulder21c

Task description

주어진 수열에서 누락된 가장 작은 양의 정수 찾기

  • 주어진 배열은 중복이 가능하고 음수도 포함되어 있다.

How I did solve

전에는 양의 정수, 고유값들로 주어진 순열 중 누락분을 구하는 문제였어서 합을 통해 풀었으나, 이번에는 일단 중복이 발생되어 있고 음수도 끼어 있어서 hashmap을 이용해서 풀어보기로 했고 의외로 금방 풀어냈음.

Solved Code

function solution(A) {
  const hashMap = {};
  A = A.sort( (a,b) => a - b);  
  A.forEach( item => {
    if( item > 0) hashMap[item] = item;
  });
  
  for(let i = 0; ++i < Number.MAX_SAFE_INTEGER;) {
    if( !hashMap.hasOwnProperty(i) ) {
      return i;
    }
  }
}

Retrospective

  • 비슷한 문제를 풀어본 경허이 있으니 어렵지 않게 해결.
  • 위와 같이 풀어보고 나서 new Set을 이용해서 중복을 제거하여 iterable을 순회해 봤는데 오히려 아주 살짝 느린 결과가 나오더라… ㅎㅎ

Hero image from pixabay