๐ ๊ฐ๋ฐ ๋ธ๋ก๊ทธ ์คํ ๐
ยท ์ฝ 3๋ถ
ํ ์คํธ ๋งํฌ ๋ค์ด ๋ฌธ์๋ฅผ ์์ฑํด๋ด ๋๋ค..
โ๏ธ๏ธ 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โ
Syntax | Description |
---|---|
Header | Title |
Paragraph | Text |