Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.DS_Store

Jiho/input.txt
29 changes: 29 additions & 0 deletions Jiho/Day1/백준10816.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const fs = require("fs");
const input = fs
.readFileSync(process.platform === "linux" ? "/dev/stdin" : "./input.txt")
.toString()
.trim()
.split("\n");

const [N, cardstr, M, arrstr] = input;
const cards = cardstr.split(" ").map(Number);
const arr = arrstr.split(" ").map(Number);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

훌륭합니다

function solution(N, cards, M, arr) {
// #1. 집합 만들기
const card_set = new Set();
for (const card of cards) {
card_set.add(card);
}
let res = "";
for (const num of arr) {
if (card_set.has(num)) {
res += "1 ";
} else {
res += "0 ";
}
}
return res;
}

console.log(solution(parseInt(N), cards, parseInt(M), arr));
30 changes: 30 additions & 0 deletions Jiho/Day1/백준1475.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require("fs");
const input = fs
.readFileSync(process.platform === "linux" ? "/dev/stdin" : "../input.txt")
.toString()
.trim();

/*--------------------------------------------------------------------------------
#1 1475번
*/
function solution(val) {
const arr = val.toString().split("");
const cnt_arr = Array(10).fill(0);
const cnt_arr69 = Array(2).fill(0);
let i;
for (i = 0; i < arr.length; i++) {
const val = parseInt(arr[i]);
if (val == 6) {
cnt_arr69[0] += 1;
} else if (val == 9) {
cnt_arr69[1] += 1;
} else {
cnt_arr[val] += 1;
}
}

const res = [...cnt_arr, Math.ceil((cnt_arr69[0] + cnt_arr69[1]) / 2)];
return Math.max(...res);
}

console.log(solution(parseInt(input)));
32 changes: 32 additions & 0 deletions Jiho/Day1/백준7785.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require("fs");
const input = fs
.readFileSync(process.platform === "linux" ? "/dev/stdin" : "./input.txt")
.toString()
.trim()
.split("\n");

const [N, ...arr] = input;
function solution(N, arr) {
const emp_set = new Set();
for (const rec of arr) {
const [name, command] = rec.trim().split(" ");
// #1. enter인 경우
if (command === "enter") {
emp_set.add(name);
}
// #2. leave인 경우
else if (command === "leave") {
if (emp_set.has(name)) {
emp_set.delete(name);
}
}
}
const emp_arr = [...emp_set];
// const sorted_arr = emp_arr.sort().reverse();
const sorted_arr = emp_arr.sort((a, b) => a.localeCompare(b));
for (const name of sorted_arr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

훌륭하군요

console.log(name);
}
}

solution(parseInt(N), arr);
Empty file removed Jiho/dummy
Empty file.