๐Ÿ… ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค 42893 : ๋งค์นญ ์ ์ˆ˜ - Javascript

๋ฌธ์ œ ์„ค๋ช…

ํ”„๋ Œ์ฆˆ ๋Œ€ํ•™๊ต ์กฐ๊ต์˜€๋˜ ์ œ์ด์ง€๋Š” ํ—ˆ๋“œ๋ ›์ผ๋งŒ ์‹œํ‚ค๋Š” ๋„ค์˜ค ํ•™๊ณผ์žฅ๋‹˜์˜ ๋งˆ์ˆ˜์—์„œ ๋ฒ—์–ด๋‚˜, ์นด์นด์˜ค์— ์ž…์‚ฌํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค. ํ‰์†Œ์— ๊ด€์‹ฌ์žˆ์–ดํ•˜๋˜ ๊ฒ€์ƒ‰์— ๋งˆ์นจ ๊ฒฐ์›์ด ๋ฐœ์ƒํ•˜์—ฌ, ๊ฒ€์ƒ‰๊ฐœ๋ฐœํŒ€์— ํŽธ์ž…๋  ์ˆ˜ ์žˆ์—ˆ๊ณ , ๋Œ€๋ง์˜ ์ฒซ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งก๊ฒŒ ๋˜์—ˆ๋‹ค. ๊ทธ ํ”„๋กœ์ ํŠธ๋Š” ๊ฒ€์ƒ‰์–ด์— ๊ฐ€์žฅ ์ž˜ ๋งž๋Š” ์›นํŽ˜์ด์ง€๋ฅผ ๋ณด์—ฌ์ฃผ๊ธฐ ์œ„ํ•ด ์•„๋ž˜์™€ ๊ฐ™์€ ๊ทœ์น™์œผ๋กœ ๊ฒ€์ƒ‰์–ด์— ๋Œ€ํ•œ ์›นํŽ˜์ด์ง€์˜ ๋งค์นญ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐ ํ•˜๋Š” ๊ฒƒ์ด์—ˆ๋‹ค.

  • ํ•œ ์›นํŽ˜์ด์ง€์— ๋Œ€ํ•ด์„œ ๊ธฐ๋ณธ์ ์ˆ˜, ์™ธ๋ถ€ ๋งํฌ ์ˆ˜, ๋งํฌ์ ์ˆ˜, ๊ทธ๋ฆฌ๊ณ  ๋งค์นญ์ ์ˆ˜๋ฅผ ๊ตฌํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ํ•œ ์›นํŽ˜์ด์ง€์˜ ๊ธฐ๋ณธ์ ์ˆ˜๋Š” ํ•ด๋‹น ์›นํŽ˜์ด์ง€์˜ ํ…์ŠคํŠธ ์ค‘, ๊ฒ€์ƒ‰์–ด๊ฐ€ ๋“ฑ์žฅํ•˜๋Š” ํšŸ์ˆ˜์ด๋‹ค. (๋Œ€์†Œ๋ฌธ์ž ๋ฌด์‹œ)
  • ํ•œ ์›นํŽ˜์ด์ง€์˜ ์™ธ๋ถ€ ๋งํฌ ์ˆ˜๋Š” ํ•ด๋‹น ์›นํŽ˜์ด์ง€์—์„œ ๋‹ค๋ฅธ ์™ธ๋ถ€ ํŽ˜์ด์ง€๋กœ ์—ฐ๊ฒฐ๋œ ๋งํฌ์˜ ๊ฐœ์ˆ˜์ด๋‹ค.
  • ํ•œ ์›นํŽ˜์ด์ง€์˜ ๋งํฌ์ ์ˆ˜๋Š” ํ•ด๋‹น ์›นํŽ˜์ด์ง€๋กœ ๋งํฌ๊ฐ€ ๊ฑธ๋ฆฐ ๋‹ค๋ฅธ ์›นํŽ˜์ด์ง€์˜ ๊ธฐ๋ณธ์ ์ˆ˜ รท ์™ธ๋ถ€ ๋งํฌ ์ˆ˜์˜ - ์ดํ•ฉ์ด๋‹ค.
  • ํ•œ ์›นํŽ˜์ด์ง€์˜ ๋งค์นญ์ ์ˆ˜๋Š” ๊ธฐ๋ณธ์ ์ˆ˜์™€ ๋งํฌ์ ์ˆ˜์˜ ํ•ฉ์œผ๋กœ ๊ณ„์‚ฐํ•œ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด, ๋‹ค์Œ๊ณผ ๊ฐ™์ด A, B, C ์„ธ ๊ฐœ์˜ ์›นํŽ˜์ด์ง€๊ฐ€ ์žˆ๊ณ , ๊ฒ€์ƒ‰์–ด๊ฐ€ hi๋ผ๊ณ  ํ•˜์ž.

example img

์ด๋•Œ A ์›นํŽ˜์ด์ง€์˜ ๋งค์นญ์ ์ˆ˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ณ„์‚ฐํ•  ์ˆ˜ ์žˆ๋‹ค.

  • ๊ธฐ๋ณธ ์ ์ˆ˜๋Š” ๊ฐ ์›นํŽ˜์ด์ง€์—์„œ hi๊ฐ€ ๋“ฑ์žฅํ•œ ํšŸ์ˆ˜์ด๋‹ค.
    • A,B,C ์›นํŽ˜์ด์ง€์˜ ๊ธฐ๋ณธ์ ์ˆ˜๋Š” ๊ฐ๊ฐ 1์ , 4์ , 9์ ์ด๋‹ค.
  • ์™ธ๋ถ€ ๋งํฌ์ˆ˜๋Š” ๋‹ค๋ฅธ ์›นํŽ˜์ด์ง€๋กœ ๋งํฌ๊ฐ€ ๊ฑธ๋ฆฐ ๊ฐœ์ˆ˜์ด๋‹ค.
    • A,B,C ์›นํŽ˜์ด์ง€์˜ ์™ธ๋ถ€ ๋งํฌ ์ˆ˜๋Š” ๊ฐ๊ฐ 1์ , 2์ , 3์ ์ด๋‹ค.
  • A ์›นํŽ˜์ด์ง€๋กœ ๋งํฌ๊ฐ€ ๊ฑธ๋ฆฐ ํŽ˜์ด์ง€๋Š” B์™€ C๊ฐ€ ์žˆ๋‹ค.
    • A ์›นํŽ˜์ด์ง€์˜ ๋งํฌ์ ์ˆ˜๋Š” B์˜ ๋งํฌ์ ์ˆ˜ 2์ (4 รท 2)๊ณผ C์˜ ๋งํฌ์ ์ˆ˜ 3์ (9 รท 3)์„ ๋”ํ•œ 5์ ์ด ๋œ๋‹ค.
  • ๊ทธ๋Ÿฌ๋ฏ€๋กœ, A ์›นํŽ˜์ด์ง€์˜ ๋งค์นญ์ ์ˆ˜๋Š” ๊ธฐ๋ณธ์ ์ˆ˜ 1์  + ๋งํฌ์ ์ˆ˜ 5์  = 6์ ์ด ๋œ๋‹ค.

๊ฒ€์ƒ‰์–ด word์™€ ์›นํŽ˜์ด์ง€์˜ HTML ๋ชฉ๋ก์ธ pages๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ๋งค์นญ์ ์ˆ˜๊ฐ€ ๊ฐ€์žฅ ๋†’์€ ์›นํŽ˜์ด์ง€์˜ index๋ฅผ ๊ตฌํ•˜๋ผ. ๋งŒ์•ฝ ๊ทธ๋Ÿฐ ์›นํŽ˜์ด์ง€๊ฐ€ ์—ฌ๋Ÿฌ ๊ฐœ๋ผ๋ฉด ๊ทธ์ค‘ ๋ฒˆํ˜ธ๊ฐ€ ๊ฐ€์žฅ ์ž‘์€ ๊ฒƒ์„ ๊ตฌํ•˜๋ผ.


์ œํ•œ์‚ฌํ•ญ

  • pages๋Š” HTML ํ˜•์‹์˜ ์›นํŽ˜์ด์ง€๊ฐ€ ๋ฌธ์ž์—ด ํ˜•ํƒœ๋กœ ๋“ค์–ด์žˆ๋Š” ๋ฐฐ์—ด์ด๊ณ , ๊ธธ์ด๋Š” 11 ์ด์ƒ 2020 ์ดํ•˜์ด๋‹ค.
  • ํ•œ ์›นํŽ˜์ด์ง€ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋Š” 11 ์ด์ƒ 1,5001,500 ์ดํ•˜์ด๋‹ค.
  • ์›นํŽ˜์ด์ง€์˜ index๋Š” pages ๋ฐฐ์—ด์˜ index์™€ ๊ฐ™์œผ๋ฉฐ 00๋ถ€ํ„ฐ ์‹œ์ž‘ํ•œ๋‹ค.
  • ํ•œ ์›นํŽ˜์ด์ง€์˜ url์€ HTML์˜ ํƒœ๊ทธ ๋‚ด์— ํƒœ๊ทธ์˜ ๊ฐ’์œผ๋กœ ์ฃผ์–ด์ง„๋‹ค.
    • ์˜ˆ๋ฅผ๋“ค์–ด, ์•„๋ž˜์™€ ๊ฐ™์€ meta tag ๊ฐ€ ์žˆ์œผ๋ฉด ์ด ์›นํŽ˜์ด์ง€์˜ url์€ https://careers.kakao.com/index ์ด๋‹ค.
    • <meta property="og:url" content="https://careers.kakao.com/index" />
  • ํ•œ ์›นํŽ˜์ด์ง€์—์„œ ๋ชจ๋“  ์™ธ๋ถ€ ๋งํฌ๋Š” <a href="https://careers.kakao.com/index">์˜ ํ˜•ํƒœ๋ฅผ ๊ฐ€์ง„๋‹ค.
    • <a> ๋‚ด์— ๋‹ค๋ฅธ attribute๊ฐ€ ์ฃผ์–ด์ง€๋Š” ๊ฒฝ์šฐ๋Š” ์—†์œผ๋ฉฐ ํ•ญ์ƒ href๋กœ ์—ฐ๊ฒฐํ•  ์‚ฌ์ดํŠธ์˜ url๋งŒ ํฌํ•จ๋œ๋‹ค.
    • ์œ„์˜ ๊ฒฝ์šฐ์—์„œ ํ•ด๋‹น ์›นํŽ˜์ด์ง€๋Š” https://careers.kakao.com/index ๋กœ ์™ธ๋ถ€๋งํฌ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๊ณ  ๋ณผ ์ˆ˜ ์žˆ๋‹ค.
  • ๋ชจ๋“  url์€ https:// ๋กœ๋งŒ ์‹œ์ž‘ํ•œ๋‹ค.
  • ๊ฒ€์ƒ‰์–ด word๋Š” ํ•˜๋‚˜์˜ ์˜์–ด ๋‹จ์–ด๋กœ๋งŒ ์ฃผ์–ด์ง€๋ฉฐ ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž์™€ ๋Œ€๋ฌธ์ž๋กœ๋งŒ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค.
  • word์˜ ๊ธธ์ด๋Š” 11 ์ด์ƒ 1212 ์ดํ•˜์ด๋‹ค.
  • ๊ฒ€์ƒ‰์–ด๋ฅผ ์ฐพ์„ ๋•Œ, ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„์€ ๋ฌด์‹œํ•˜๊ณ  ์ฐพ๋Š”๋‹ค.
    • ์˜ˆ๋ฅผ๋“ค์–ด ๊ฒ€์ƒ‰์–ด๊ฐ€ blind์ผ ๋•Œ, HTML ๋‚ด์— Blind๋ผ๋Š” ๋‹จ์–ด๊ฐ€ ์žˆ๊ฑฐ๋‚˜, BLIND๋ผ๋Š” ๋‹จ์–ด๊ฐ€ ์žˆ์œผ๋ฉด ๋‘ ๊ฒฝ์šฐ ๋ชจ๋‘ ํ•ด๋‹น๋œ๋‹ค.
  • ๊ฒ€์ƒ‰์–ด๋Š” ๋‹จ์–ด ๋‹จ์œ„๋กœ ๋น„๊ตํ•˜๋ฉฐ, ๋‹จ์–ด์™€ ์™„์ „ํžˆ ์ผ์น˜ํ•˜๋Š” ๊ฒฝ์šฐ์—๋งŒ ๊ธฐ๋ณธ ์ ์ˆ˜์— ๋ฐ˜์˜ํ•œ๋‹ค.
    • ๋‹จ์–ด๋Š” ์•ŒํŒŒ๋ฒณ์„ ์ œ์™ธํ•œ ๋‹ค๋ฅธ ๋ชจ๋“  ๋ฌธ์ž๋กœ ๊ตฌ๋ถ„ํ•œ๋‹ค.
    • ์˜ˆ๋ฅผ๋“ค์–ด ๊ฒ€์ƒ‰์–ด๊ฐ€ โ€œabaโ€ ์ผ ๋•Œ, โ€œabab abababaโ€๋Š” ๋‹จ์–ด ๋‹จ์œ„๋กœ ์ผ์น˜ํ•˜๋Š”๊ฒŒ ์—†์œผ๋‹ˆ, ๊ธฐ๋ณธ ์ ์ˆ˜๋Š” 0์ ์ด ๋œ๋‹ค.
    • ๋งŒ์•ฝ ๊ฒ€์ƒ‰์–ด๊ฐ€ โ€œabaโ€ ๋ผ๋ฉด, โ€œaba@aba abaโ€๋Š” ๋‹จ์–ด ๋‹จ์œ„๋กœ ์„ธ๊ฐœ๊ฐ€ ์ผ์น˜ํ•˜๋ฏ€๋กœ, ๊ธฐ๋ณธ ์ ์ˆ˜๋Š” 3์ ์ด๋‹ค.
  • ๊ฒฐ๊ณผ๋ฅผ ๋Œ๋ ค์ค„๋•Œ, ๋™์ผํ•œ ๋งค์นญ์ ์ˆ˜๋ฅผ ๊ฐ€์ง„ ์›นํŽ˜์ด์ง€๊ฐ€ ์—ฌ๋Ÿฌ ๊ฐœ๋ผ๋ฉด ๊ทธ์ค‘ index ๋ฒˆํ˜ธ๊ฐ€ ๊ฐ€์žฅ ์ž‘์€ ๊ฒƒ๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค
    • ์ฆ‰, ์›นํŽ˜์ด์ง€๊ฐ€ ์„ธ๊ฐœ์ด๊ณ , ๊ฐ๊ฐ ๋งค์นญ์ ์ˆ˜๊ฐ€ 3,1,3 ์ด๋ผ๋ฉด ์ œ์ผ ์ ์€ index ๋ฒˆํ˜ธ์ธ 0์„ ๋ฆฌํ„ดํ•˜๋ฉด ๋œ๋‹ค.

์ž…์ถœ๋ ฅ ์˜ˆ

์˜ˆ์‹œ #1

  • word : blind

  • pages :

    [
      "<html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">\n<head>\n  <meta charset="utf-8">\n  <meta property="og:url" content="https://a.com"/>\n</head>  \n<body>\nBlind Lorem Blind ipsum dolor Blind test sit amet, consectetur adipiscing elit. \n<a href="https://b.com"> Link to b </a>\n</body>\n</html>",
      "<html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">\n<head>\n  <meta charset="utf-8">\n  <meta property="og:url" content="https://b.com"/>\n</head>  \n<body>\nSuspendisse potenti. Vivamus venenatis tellus non turpis bibendum, \n<a href="https://a.com"> Link to a </a>\nblind sed congue urna varius. Suspendisse feugiat nisl ligula, quis malesuada felis hendrerit ut.\n<a href="https://c.com"> Link to c </a>\n</body>\n</html>",
      "<html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">\n<head>\n  <meta charset="utf-8">\n  <meta property="og:url" content="https://c.com"/>\n</head>  \n<body>\nUt condimentum urna at felis sodales rutrum. Sed dapibus cursus diam, non interdum nulla tempor nec. Phasellus rutrum enim at orci consectetu blind\n<a href="https://a.com"> Link to a </a>\n</body>\n</html>"
    ]
  • pages๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด 3๊ฐœ์˜ ์›นํŽ˜์ด์ง€์— ํ•ด๋‹นํ•˜๋Š” HTML ๋ฌธ์ž์—ด์ด ์ˆœ์„œ๋Œ€๋กœ ๋“ค์–ด์žˆ๋‹ค.

    <html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta charset="utf-8">
      <meta property="og:url" content="https://a.com"/>
    </head>
    <body>
    Blind Lorem Blind ipsum dolor Blind test sit amet, consectetur adipiscing elit.
    <a href="https://b.com"> Link to b </a>
    </body>
    </html>
    <html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta charset="utf-8">
      <meta property="og:url" content="https://b.com"/>
    </head>
    <body>
    Suspendisse potenti. Vivamus venenatis tellus non turpis bibendum,
    <a href="https://a.com"> Link to a </a>
    blind sed congue urna varius. Suspendisse feugiat nisl ligula, quis malesuada felis   hendrerit ut.
    <a href="https://c.com"> Link to c </a>
    </body>
    </html>
    <html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta charset="utf-8">
      <meta property="og:url" content="https://c.com"/>
    </head>
    <body>
    Ut condimentum urna at felis sodales rutrum. Sed dapibus cursus diam, non interdum nulla  tempor nec. Phasellus rutrum enim at orci consectetu blind
    <a href="https://a.com"> Link to a </a>
    </body>
    </html>

์œ„์˜ ์˜ˆ๋ฅผ ๊ฐ€์ง€๊ณ  ๊ฐ๊ฐ์˜ ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•ด๋ณด์ž.

  • ๊ธฐ๋ณธ์ ์ˆ˜ ๋ฐ ์™ธ๋ถ€ ๋งํฌ์ˆ˜๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.
    • a.com์˜ ๊ธฐ๋ณธ์ ์ˆ˜๋Š” 3, ์™ธ๋ถ€ ๋งํฌ ์ˆ˜๋Š” 1๊ฐœ
    • b.com์˜ ๊ธฐ๋ณธ์ ์ˆ˜๋Š” 1, ์™ธ๋ถ€ ๋งํฌ ์ˆ˜๋Š” 2๊ฐœ
    • c.com์˜ ๊ธฐ๋ณธ์ ์ˆ˜๋Š” 1, ์™ธ๋ถ€ ๋งํฌ ์ˆ˜๋Š” 1๊ฐœ
  • ๋งํฌ์ ์ˆ˜๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.
    • a.com์˜ ๋งํฌ์ ์ˆ˜๋Š” b.com์œผ๋กœ๋ถ€ํ„ฐ 0.5์ , c.com์œผ๋กœ๋ถ€ํ„ฐ 1์ 
    • b.com์˜ ๋งํฌ์ ์ˆ˜๋Š” a.com์œผ๋กœ๋ถ€ํ„ฐ 3์ 
    • c.com์˜ ๋งํฌ์ ์ˆ˜๋Š” b.com์œผ๋กœ๋ถ€ํ„ฐ 0.5์ 
  • ๊ฐ ์›น ํŽ˜์ด์ง€์˜ ๋งค์นญ ์ ์ˆ˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.
    • a.com : 4.5 ์ 
    • b.com : 4 ์ 
    • c.com : 1.5 ์ 

๋”ฐ๋ผ์„œ ๋งค์นญ์ ์ˆ˜๊ฐ€ ์ œ์ผ ๋†’์€ ์ฒซ๋ฒˆ์งธ ์›น ํŽ˜์ด์ง€์˜ index์ธ 0์„ ๋ฆฌํ„ด ํ•˜๋ฉด ๋œ๋‹ค.


์˜ˆ์‹œ #2

  • word : Muzi

  • pages :

    [
      "<html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">\n<head>\n  <meta charset="utf-8">\n  <meta property="og:url" content="https://careers.kakao.com/interview/list"/>\n</head>  \n<body>\n<a href="https://programmers.co.kr/learn/courses/4673"></a>#!MuziMuzi!)jayg07con&&\n\n</body>\n</html>",
      "<html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">\n<head>\n  <meta charset="utf-8">\n  <meta property="og:url" content="https://www.kakaocorp.com"/>\n</head>  \n<body>\ncon%\tmuzI92apeach&2<a href="https://hashcode.co.kr/tos"></a>\n\n\t^\n</body>\n</html>"
    ]
  • pages๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด 2๊ฐœ์˜ ์›นํŽ˜์ด์ง€์— ํ•ด๋‹นํ•˜๋Š” HTML ๋ฌธ์ž์—ด์ด ์ˆœ์„œ๋Œ€๋กœ ๋“ค์–ด์žˆ๋‹ค.

    <html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta charset="utf-8">
      <meta property="og:url" content="https://careers.kakao.com/interview/list"/>
    </head>
    <body>
    <a href="https://programmers.co.kr/learn/courses/4673"></a>#!MuziMuzi!)jayg07con&&
    
    </body>
    </html>
    <html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta charset="utf-8">
      <meta property="og:url" content="https://www.kakaocorp.com"/>
    </head>
    <body>
    con%    muzI92apeach&2<a href="https://hashcode.co.kr/tos"></a>
    
        ^
    </body>
    </html>

์œ„์˜ ์˜ˆ๋ฅผ ๊ฐ€์ง€๊ณ  ๊ฐ๊ฐ์˜ ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•ด๋ณด์ž.

  • ๊ธฐ๋ณธ์ ์ˆ˜ ๋ฐ ์™ธ๋ถ€ ๋งํฌ์ˆ˜๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.
    • careers.kakao.com/interview/list ์˜ ๊ธฐ๋ณธ์ ์ˆ˜๋Š” 0, ์™ธ๋ถ€ ๋งํฌ ์ˆ˜๋Š” 1๊ฐœ
    • www.kakaocorp.com ์˜ ๊ธฐ๋ณธ์ ์ˆ˜๋Š” 1, ์™ธ๋ถ€ ๋งํฌ ์ˆ˜๋Š” 1๊ฐœ
  • ๋งํฌ์ ์ˆ˜๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.
    • careers.kakao.com/interview/list ์˜ ๋งํฌ์ ์ˆ˜๋Š” 0์ 
    • www.kakaocorp.com ์˜ ๋งํฌ์ ์ˆ˜๋Š” 0์ 
  • ๊ฐ ์›น ํŽ˜์ด์ง€์˜ ๋งค์นญ ์ ์ˆ˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.
    • careers.kakao.com/interview/list : 0์ 
    • www.kakaocorp.com : 1 ์ 

๋”ฐ๋ผ์„œ ๋งค์นญ์ ์ˆ˜๊ฐ€ ์ œ์ผ ๋†’์€ ๋‘๋ฒˆ์งธ ์›น ํŽ˜์ด์ง€์˜ index์ธ 1์„ ๋ฆฌํ„ด ํ•˜๋ฉด ๋œ๋‹ค.


ํ’€์ด ๊ณผ์ •

ํŠน๋ณ„ํ•œ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ํ•„์š”ํ•˜๊ธฐ๋ณด๋‹จ ๋ฌธ์ž์—ด ํŒŒ์‹ฑ์„ ์ž˜ ํ•ด์•ผํ•˜๋Š” ๋ฌธ์ œ๋ผ ๋ณ„ ๊ณ ๋ฏผ ์—†์ด ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.

๋จผ์ € ์•„๋ž˜์™€ ๊ฐ™์ด ํŽ˜์ด์ง€ ๊ฐ’์„ ํŒŒ์‹ฑํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.

const parsePage = (page, index, word) => {
  //ํŽ˜์ด์ง€์˜ ์ฃผ์†Œ์™€ ์™ธ๋ถ€ ๋งํฌ๋Š” ์ •๊ทœ์‹์„ ํ†ตํ•ด ์ฐพ์„ ์ˆ˜ ์žˆ๋‹ค
  const url = page.match(/<meta property="og:url" content="(.+?)"/i)[1];

  //ํŽ˜์ด์ง€์˜ body ๋‚ด์šฉ์„ ๊ฐ€์ ธ์™€ ๋ฏธ๋ฆฌ ์†Œ๋ฌธ์žํ™”ํ•œ๋‹ค
  let body = page.match(/<body>([wW]+)</body>/i)[1].toLowerCase();

  //replaceAll์˜ ์ฝœ๋ฐฑ ํ•จ์ˆ˜๋กœ ์™ธ๋ถ€ ๋งํฌ๋ฅผ ์ˆ˜์ง‘ํ•˜๊ณ  body์—์„œ ์ œ๊ฑฐ
  const externalUrls = [];
  body = body.replaceAll(/<a href="(.+?)">/gi, (_, externalUrl) => {
    externalUrls.push(externalUrl);
    return '';
  });

  //์•ž๋’ค๊ฐ€ ์˜๋ฌธ์ž๊ฐ€ ์•„๋‹Œ๋ฐ, ๋‹จ์–ด์™€ ์ผ์น˜ํ•˜๋Š” ๊ฒฝ์šฐ์˜ ๊ฐฏ์ˆ˜๋ฅผ ๊ธฐ๋ณธ ์ ์ˆ˜๋กœ ์‚ฌ์šฉ
  const basePoint = (body.match(new RegExp(`[^a-z]${word}[^a-z]`, 'ig')) || [])
    .length;

  //ํŒŒ์‹ฑ ๊ฒฐ๊ณผ๋ฅผ ๊ฐ์ฒด๋กœ ๋ฐ˜ํ™˜
  return {
    index,
    url,
    externalUrls,
    basePoint,
    totalPoint: basePoint
  };
};

๊ทธ ํ›„ ํŽ˜์ด์ง€๋ฅผ ํŒŒ์‹ฑํ•œ ๊ฒฐ๊ณผ๋ฅผ Map์— ๋‹ด์•˜์Šต๋‹ˆ๋‹ค. ์›๋ž˜ ๋ฐฐ์—ด์„ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ, ์™ธ๋ถ€ ๋งํฌ ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•  ๋•Œ url์„ ํ‚ค๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด Map์„ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.

๋งคํ•‘์ด ๋๋‚œ ํ›„์— ์™ธ๋ถ€ ๋งํฌ ์ ์ˆ˜๋ฅผ totalPoint์— ๋”ํ•ด ์ด ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•˜๊ณ , ์ด์ ์ˆ˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌํ•œ ๊ฒฐ๊ณผ์˜ ์ฒซ๋ฒˆ์งธ ์š”์†Œ์˜ ์ธ๋ฑ์Šค๋ฅผ ๋ฐ˜ํ™˜ํ–ˆ์Šต๋‹ˆ๋‹ค.

function solution(word, pages) {
  //์ž…๋ ฅ๋œ ๋ฐ์ดํ„ฐ ๋ถ„์„ ํ›„ ๋งคํ•‘
  const pageInfos = new Map(
    pages.map((page, index) => {
      const parsed = parsePage(page, index, word);
      return [parsed.url, parsed];
    })
  );

  //์™ธ๋ถ€ ๋งํฌ ์ ์ˆ˜ ๋ถ€์—ฌ ์ฒ˜๋ฆฌ
  for (const page of pageInfos.values()) {
    const additionalPoint = page.basePoint / page.externalUrls.length;
    for (const externalUrl of page.externalUrls) {
      if (pageInfos.has(externalUrl)) {
        pageInfos.get(externalUrl).totalPoint += additionalPoint;
      }
    }
  }

  //์ด์ ์ˆ˜๋ฅผ ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•˜๊ณ  ์ฒซ๋ฒˆ์งธ ํŽ˜์ด์ง€์˜ ์ธ๋ฑ์Šค๋ฅผ ๋ฐ˜ํ™˜
  return [...pageInfos.values()].sort((a, b) => b.totalPoint - a.totalPoint)[0]
    .index;
}

ํ•˜์ง€๋งŒ ์ด๋ ‡๊ฒŒ ์ž‘์„ฑํ•œ ์ฝ”๋“œ์˜ ๊ฒฝ์šฐ ์ž…๋ ฅ ์˜ˆ์ œ 2๊ฐ€์ง€๋Š” ํ†ต๊ณผํ–ˆ์ง€๋งŒ, ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค 1,2,9,12๋ฅผ ํ†ต๊ณผํ•˜์ง€ ๋ชปํ•ด ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค. ํ…Œ์ŠคํŠธ์ผ€์ด์Šค๋Š” ๋น„๊ณต๊ฐœ์ด๊ธฐ ๋•Œ๋ฌธ์— ์–ด๋–ค ์ž…๋ ฅ์— ์‹คํŒจํ•˜๋Š”์ง€ ์ง์ ‘ ์ฐพ์•„ ํ•ด๊ฒฐํ•ด์•ผ๋งŒ ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋•Œ๋ฌธ์— ๋ฌธ์ œ์— ์ ํžŒ ๋ชจ๋“  ์กฐ๊ฑด์˜ ๋ฐ˜๋ก€๊ฐ€ ๋ ๋งŒํ•œ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋ฅผ ์ง์ ‘ ์ถ”๊ฐ€ํ•ด์„œ ์‹คํ–‰ํ•ด๋ดค์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋˜ ์ค‘ ๋ฌธ์ œ ์กฐ๊ฑด์˜ ์˜ˆ๋ฅผ๋“ค์–ด ๊ฒ€์ƒ‰์–ด๊ฐ€ "aba" ์ผ ๋•Œ, "abab abababa"๋Š” ๋‹จ์–ด ๋‹จ์œ„๋กœ ์ผ์น˜ํ•˜๋Š”๊ฒŒ ์—†์œผ๋‹ˆ, ๊ธฐ๋ณธ ์ ์ˆ˜๋Š” 0์ ์ด ๋œ๋‹ค๋ผ๋Š” ๋ถ€๋ถ„์„ ๊ตฌํ˜„ํ•œ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋ฅผ ์ถ”๊ฐ€ํ•œ ์ˆœ๊ฐ„ ๋“œ๋””์–ด ์ œ ์ฝ”๋“œ๊ฐ€ ํ†ต๊ณผํ•˜์ง€ ๋ชปํ•˜๋Š” ํ…Œ์ŠคํŠธ์ผ€์ด์Šค๋ฅผ ์ฐพ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

์›์ธ์€ ๋ฐ”๋กœ ๊ธฐ๋ณธ ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•˜๋Š” ๋ถ€๋ถ„์—์„œ ์ €์ง€๋ฅธ ์‹ค์ˆ˜ ๋•Œ๋ฌธ์ด์˜€์Šต๋‹ˆ๋‹ค.

const basePoint = (body.match(new RegExp(`[^a-z]${word}[^a-z]`, 'ig')) || [])
  .length;

๋‹จ์ˆœํžˆ bodyํƒœ๊ทธ ๋‚ด์—๋Š” ์ตœ์†Œํ•œ ๋‹จ์–ด ์–‘์ชฝ์— ๋„์–ด์“ฐ๊ธฐ๋ผ๋„ ์žˆ์„ํ…Œ๋‹ˆ ์•ž๋’ค๊ฐ€ ์˜๋ฌธ์ž๊ฐ€ ์•„๋‹Œ๋ฐ, word์™€ ์ผ์น˜ํ•˜๋ฉด ๋ ๊ฑฐ๋ผ๊ณ  ์ƒ๊ฐํ–ˆ์—ˆ๋Š”๋ฐ, ์ด๋ ‡๊ฒŒ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ฒฝ์šฐ ์˜๋ฌธ์ž ์‚ฌ์ด์— ํ•œ๊ธ€์ž๋งŒ ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ ๋‹ค์Œ ์˜๋ฌธ์ž๋ฅผ ๊ทธ๋ƒฅ ๋„˜์–ด๊ฐ€๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด 1abc2def3ghi4๋ผ๋Š” ๋ฌธ์ž์—ด์— ๋Œ€ํ•ด ์ •๊ทœ์‹ /[^a-z][a-z]+[^a-z]/g ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋ฉด ๊ฒฐ๊ณผ๋Š” ['1abc2', '3ghi4']์ž…๋‹ˆ๋‹ค. 2def3์ด ํฌํ•จ๋˜์ง€ ์•Š์€ ์ด์œ ๋Š” ์ •๊ทœ์‹์ด ์•„๋ž˜์™€ ๊ฐ™์ด ์ž‘๋™ํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

์ฒ˜๋ฆฌ์ค‘์ธ ๋ฌธ์ž โ€ฆ ํ™•์ธ์ค‘์ธ ๋ฌธ์ž์—ด ๋‚จ์€ ๋ฌธ์ž์—ด
1 [^a-z]์ผ์น˜ 1 abc2def3ghi4
a [a-z]+์ผ์น˜ 1a bc2def3ghi4
b [a-z]+์ผ์น˜ 1ab c2def3ghi4
c [a-z]+์ผ์น˜ 1abc 2def3ghi4
2 [^a-z]์ผ์น˜ - ๋งค์นญ ์™„๋ฃŒ 1abc2 def3ghi4
d [^a-z]๋ถˆ์ผ์น˜ ef3ghi4
e [^a-z]๋ถˆ์ผ์น˜ f3ghi4
f [^a-z]๋ถˆ์ผ์น˜ 3ghi4
3 [^a-z]์ผ์น˜ 3 ghi4
g [a-z]+์ผ์น˜ 3g hi4
h [a-z]+์ผ์น˜ 3gh i4
i [a-z]+์ผ์น˜ 3ghi 4
4 [^a-z]์ผ์น˜ - ๋งค์นญ ์™„๋ฃŒ 3ghi4

๊ณ ๋ž˜ ์‹ธ์›€์— ์ƒˆ์šฐ def๋Š” ๋“ฑ์ด ํ„ฐ์ ธ๋ฒ„๋ ธ์Šต๋‹ˆ๋‹ค!

์ด๋Ÿฐ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ๋ชจ๋“  ์˜๋‹จ์–ด๋ฅผ ๊ฐ€์ ธ์˜จ ๋’ค ์ฐพ์•„์•ผํ•  ๋‹จ์–ด์™€ ๋น„๊ตํ•ด ์ผ์น˜ํ•˜๋Š” ํšŸ์ˆ˜๋ฅผ ๊ธฐ๋ณธ์ ์ˆ˜๋กœ ์‚ฌ์šฉํ•˜๋„๋ก ์•„๋ž˜์™€ ๊ฐ™์ด ์ˆ˜์ •ํ–ˆ๊ณ , ์ด์ œ ๋ชจ๋“  ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋ฅผ ์ž˜ ํ†ต๊ณผํ•ฉ๋‹ˆ๋‹ค.

const basePoint = body
  .match(/[a-z]+/gi)
  .filter((match) => match === word.toLowerCase()).length;

๋‹ค๋ฅธ ๋ถ„๋“ค์€ ์ €์ฒ˜๋Ÿผ ์ •๊ทœ์‹์„ ์ž˜ ๋ชจ๋ฅด๋ฉด์„œ ์ •๊ทœ์‹์„ ๋งน์‹ ํ•˜๋Š” ์ผ์ด ์—†๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹คโ€ฆ ์ด๊ฑธ ๋ชฐ๋ผ์„œ ์ฝ”๋“œ์˜ ์˜จ๊ฐ– ๋ถ€๋ถ„์„ ๋‹ค ๊ฐˆ์•„ ์—Ž๊ณ  ๋‚œ๋ฆฌ ์ณค์–ด์š”ใ… ใ… 

์ตœ์ข… ์ฝ”๋“œ
const parsePage = (page, index, word) => {
  //ํŽ˜์ด์ง€์˜ ์ฃผ์†Œ์™€ ์™ธ๋ถ€ ๋งํฌ๋Š” ์ •๊ทœ์‹์„ ํ†ตํ•ด ์ฐพ์„ ์ˆ˜ ์žˆ๋‹ค
  const url = page.match(/<meta property="og:url" content="(.+?)"/i)[1];

  //ํŽ˜์ด์ง€์˜ body ๋‚ด์šฉ์„ ๊ฐ€์ ธ์™€ ๋ฏธ๋ฆฌ ์†Œ๋ฌธ์žํ™”ํ•œ๋‹ค
  let body = page.match(/<body>([wW]+)</body>/i)[1].toLowerCase();

  //replaceAll์˜ ์ฝœ๋ฐฑ ํ•จ์ˆ˜๋กœ ์™ธ๋ถ€ ๋งํฌ๋ฅผ ์ˆ˜์ง‘ํ•˜๊ณ  body์—์„œ ์ œ๊ฑฐ
  const externalUrls = [];
  body = body.replaceAll(/<a href="(.+?)">/gi, (_, externalUrl) => {
    externalUrls.push(externalUrl);
    return '';
  });

  //body์˜ ๋ชจ๋“  ์˜๋‹จ์–ด๋ฅผ ๊ฒ€์‚ฌํ•ด ํŽ˜์ด์ง€์˜ ๊ธฐ๋ณธ ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐ
  const basePoint = body
    .match(/[a-z]+/gi)
    .filter((match) => match === word.toLowerCase()).length;

  return {
    index,
    url,
    externalUrls,
    basePoint,
    totalPoint: basePoint
  };
};

function solution(word, pages) {
  //์ž…๋ ฅ๋œ ๋ฐ์ดํ„ฐ ๋ถ„์„ ํ›„ ๋งคํ•‘
  const pageInfos = new Map(
    pages.map((page, index) => {
      const parsed = parsePage(page, index, word);
      return [parsed.url, parsed];
    })
  );

  //๋งคํ•‘๋œ ๋ฐ์ดํ„ฐ๋กœ ์™ธ๋ถ€ ๋งํฌ ์ ์ˆ˜ ๋ถ€์—ฌ ์ฒ˜๋ฆฌ
  for (const page of pageInfos.values()) {
    const additionalPoint = page.basePoint / page.externalUrls.length;
    for (const externalUrl of page.externalUrls) {
      if (pageInfos.has(externalUrl)) {
        pageInfos.get(externalUrl).totalPoint += additionalPoint;
      }
    }
  }

  //์ด์ ์ˆ˜๋ฅผ ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•˜๊ณ  ์ฒซ๋ฒˆ์งธ ํŽ˜์ด์ง€์˜ ์ธ๋ฑ์Šค๋ฅผ ๋ฐ˜ํ™˜
  return [...pageInfos.values()].sort((a, b) => b.totalPoint - a.totalPoint)[0]
    .index;
}