๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

๐ŸŽ‰ ๊ฐœ๋ฐœ ๋ธ”๋กœ๊ทธ ์˜คํ”ˆ ๐ŸŽ‰

ยท ์•ฝ 3๋ถ„
Johny Cho
Back End Engineer @ NHN

ํ…Œ์ŠคํŠธ ๋งˆํฌ ๋‹ค์šด ๋ฌธ์„œ๋ฅผ ์ž‘์„ฑํ•ด๋ด…๋‹ˆ๋‹ค..

โœ”๏ธ๏ธ Glorious Demo with TypeScriptโ€‹


์•„๋ž˜๋Š” glorious-demo๋ฅผ ์ด์šฉํ•œ ์—๋””ํ„ฐ + ํ„ฐ๋ฏธ๋„ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค.

Loading terminal...







โœ”๏ธ Javascript ์ฝ”๋“œ ๋ธ”๋Ÿญโ€‹


<button onClick={() => alert('button clicked!')}>Click me!</button>

โœ”๏ธ Java ์ฝ”๋“œ ๋ธ”๋Ÿญโ€‹


package com.nhn.meta.banword.application;

import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.stream.Collectors;

public class Solution {

public static void main(String[] args) {
// ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค ์‹คํ–‰ ๋ฐ ๊ฒฐ๊ณผ ์ถœ๋ ฅ
System.out.println("Test Case 1 Result: " + solution(2, "1A 2F 1C") + " (Expected: 2)");
System.out.println("Test Case 2 Result: " + solution(3, "") + " (Expected: 6)");
System.out.println(
"Test Case 3 Result: " + solution(1, "1A 1B 1C 1D 1E 1F 1G 1H 1J 1K") + " (Expected: 0)");
System.out.println(
"Test Case 4 Result: " + solution(50, "1A 3C 2B 20G 5A 7K 40D 50H") + " (Expected: 95)");
System.out.println(
"Test Case 5 Result: " + solution(2, "1A 1C 1D 1F 1G 1J 2C 2H") + " (Expected: 1)");
System.out.println(
"Test Case 6 Result: " + solution(22, "1A 3C 2B 20G 5A") + " (Expected: 41)");
}

public static int solution(int N, String S) {
final Map<String, Boolean> reserved = splitStringToMap(S);

int maxFamilies = 0;

for (int row = 1; row <= N; row++) {
boolean leftAndCenter =
!reserved.containsKey(row + "B") &&
!reserved.containsKey(row + "C") &&
!reserved.containsKey(row + "D") &&
!reserved.containsKey(row + "E");

boolean centerOnly =
!reserved.containsKey(row + "D") &&
!reserved.containsKey(row + "E") &&
!reserved.containsKey(row + "F") &&
!reserved.containsKey(row + "G");

boolean centerAndRight =
!reserved.containsKey(row + "F") &&
!reserved.containsKey(row + "G") &&
!reserved.containsKey(row + "H") &&
!reserved.containsKey(row + "J");

int familiesAdded = 0; // ๋””๋ฒ„๊น…์šฉ ์ถ”๊ฐ€
if (leftAndCenter) {
maxFamilies++;
familiesAdded++;
}

if (centerAndRight) {
maxFamilies++;
familiesAdded++;
}

if (!leftAndCenter && !centerAndRight && centerOnly) {
maxFamilies++;
familiesAdded++;
}

// ํ–‰๋ณ„๋กœ ์ถ”๊ฐ€๋œ ๊ฐ€์กฑ ์ˆ˜ ์ถœ๋ ฅ
System.out.printf(
"Row %d: leftAndCenter=%b, centerOnly=%b, centerAndRight=%b, Families added=%d\n",
row, leftAndCenter, centerOnly, centerAndRight, familiesAdded);
}

return maxFamilies;
}

public static Map<String, Boolean> splitStringToMap(String s) {
if (s == null || s.trim().isEmpty()) {
return Collections.emptyMap(); // ๋ฌธ์ž์—ด์ด ๋น„์–ด์žˆ์œผ๋ฉด ๋นˆ ๋งต ๋ฐ˜ํ™˜
}

// ๊ณต๋ฐฑ ๊ธฐ์ค€์œผ๋กœ ๋‚˜๋ˆˆ ํ›„, ๊ฐ ๋‹จ์–ด๋ฅผ ํ‚ค๋กœ, ๋‹จ์–ด์˜ ๊ธธ์ด๋ฅผ ๊ฐ’์œผ๋กœ ๋งต์— ์ €์žฅ
return Arrays.stream(s.split("\\s+")) // ๊ณต๋ฐฑ ๊ธฐ์ค€์œผ๋กœ ๋ฌธ์ž์—ด ๋ถ„๋ฆฌ
.filter(word -> !word.isEmpty()) // ๋น„์–ด ์žˆ๋Š” ๋ฌธ์ž์—ด ์ œ๊ฑฐ
.collect(Collectors.toMap(word -> word, word -> true));
}
}

โœ”๏ธ Task Listโ€‹


  • Write the press release
  • Update the website
  • Contact the media

โœ”๏ธ Using Emoji Shortcodesโ€‹


Gone camping! โ›บ Be back soon.

That is so funny! ๐Ÿ˜‚

โœ”๏ธ Highlightโ€‹


I need to highlight these very important words.

โœ”๏ธ Tableโ€‹


SyntaxDescription
HeaderTitle
ParagraphText