Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1259 #74

Open
wants to merge 9 commits into
base: recently
Choose a base branch
from
35 changes: 35 additions & 0 deletions javascript/manager/algorithm/README-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 🧠AlgorithmType

> Descriptions

- ### 🧩개념
- Descriptions
- ### 👀특징
- Descriptions.

---

# 📌핵심 이론

- Descriptions
- Descriptions

---

# 📝문제예시

> - Descriptions

- Descriptions [[링크]("풀이방식")]

# ✍풀이방식

1. Descriptions

---

# 👨‍💻Summary

> ### 🔥KeyWord
>
> - Descriptions
50 changes: 50 additions & 0 deletions javascript/manager/algorithm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 🧠DynamicProgramming (A.K.A DP)

> DynamicProgramming, DP, 동적 계획법

- ### 🧩개념
- 간단한 문제로 분리하여 부분의 문제들을 해결함으로써 최종적으로 복잡한 문제의 답을 구하는 방법을 뜻한다.
- ### 👀특징
- 자주 나오는 알고리즘 문제이며 범위가 워낙 넓다.

---

# 📌핵심 이론

- 큰 문제를 작은 문제로 나눠야한다.
- 점화식(재귀식)으로 풀어낼 수 있다.
- 작은 문제들이 반복돼 나타나고 사용되며 작은 문네들의 결괏값은 항상 같아야 한다. [[링크](https://ko.wikipedia.org/wiki/%EC%A0%90%ED%99%94%EC%8B%9D "점화식 wiki")]
- 작은 문제들은 한 번만 계산(함수)해서 return해야 한다. DP테이블을 이용한다. 이를 **메모이제이션** 기법 이라고 한다.
- 시간복잡도 측면에서 유리하다.
- **메모이제이션**은 **백트래킹** 알고리즘과 유사하다.
- DP는 **톱-다운** 방식과 **바텀-업** 방식으로 구현 할 수 있다.

---

# 📝문제예시

> - 대표적인 DP가 적용되는 사례 : 피보나치 수열 공식
> - 공식: D[N] = D[N - 1] + D[N - 2]
> - baekjoon: [2747](https://www.acmicpc.net/problem/2747 "2747 baekjoon")

- 문제: 피보나치 수열로 `[1,x,2,y,5,z]` 이루어진 배열 x,y,z를 구하시오. [[링크]("풀이방식")]

# ✍풀이방식

1. DP로 풀수 있는지 확인하기
2. 점화식 세우기
> 논리적으로 문제를 나누고, 문제간의 **인과 관계**를 파악하는 훈련이 필요하다. [[section9 조합](https://www.inflearn.com/course/lecture?courseSlug=%EB%91%90%EC%9E%87-%EC%95%8C%EA%B3%A0%EB%A6%AC%EC%A6%98-%EC%BD%94%EB%94%A9%ED%85%8C%EC%8A%A4%ED%8A%B8-%ED%8C%8C%EC%9D%B4%EC%8D%AC&unitId=148402&tab=curriculum "inflean")]
3. 메모제이션 원리 이해하기
> DP테이블에 저장해 놓는다.
4. 톱-다운 구현 방식 이해하기
> 위에서부터 문제를 파악해 내려오는 방식, 재귀함수 형태로 코드를 구현 단, 탑다운 방식은 재귀 함수의 형태로 구현 되기에 **재귀**의 깊이가 매우 길어질 경우 **런타임 에러**가 발생 할 수 있다. 이럴 경우 **바턴-업으로 구현, 최적화 필수**

---

# 👨‍💻Summary

> ### 🔥KeyWord
>
> - 점화식
> - 톱-다운, 바텀-업
> - 풀이방식
Empty file.
Empty file.
5 changes: 4 additions & 1 deletion javascript/source/dev/stdin
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Hello, World!
121
1231
12421
0
19 changes: 14 additions & 5 deletions javascript/source/printer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
let path = require('path');
let inputPath = path.join(__dirname, '/dev/stdin'); // __dirname은 현재 스크립트의 디렉토리 절대경로
let input = require('fs').readFileSync(inputPath).toString().trim().split('\r\n');
//let input = require('fs').readFileSync('/dev/stdin').toString().trim().split('\n'); //백준 제출
let path = require("path");
let inputPath = path.join(__dirname, "/dev/stdin"); // __dirname은 현재 스크립트의 디렉토리 절대경로
let input = require("fs")
.readFileSync(inputPath)
.toString()
.trim()
.split("\r\n");
//let input = require('fs').readFileSync('/dev/stdin').toString().trim().split(''); //백준 제출

console.log('Hello, World!');
input.filter((el) => {
if (el === "0") return false; // 0인 경우 제거
let newEl = el.split("").reverse().join("");
console.log(el === newEl ? "yes" : "no");
return true;
});
2 changes: 2 additions & 0 deletions javascript/source/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const test = require('./test/test');
const boolean = require('./test/boolean');
14 changes: 14 additions & 0 deletions javascript/source/test/filter.Multi-DimensionalArray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const nested = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
];

const filteredNested = nested.map((arr) => arr.filter((num) => num % 2 === 0));

console.log(filteredNested);
// [
// [2],
// [4, 6],
// [8]
// ]
5 changes: 5 additions & 0 deletions javascript/source/test/filter.include.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const words = ["apple", "banana", "cherry", "date"];

const wordsWithA = words.filter((word) => word.includes("a"));

console.log(wordsWithA); // ['apple', 'banana', 'date']
7 changes: 7 additions & 0 deletions javascript/source/test/filter.indexOf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const numbers = [1, 2, 2, 3, 4, 4, 5];

const uniqueNumbers = numbers.filter(
(num, index, array) => array.indexOf(num) === index
);

console.log(uniqueNumbers); // [1, 2, 3, 4, 5]
5 changes: 5 additions & 0 deletions javascript/source/test/filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const numbers = [1, 2, 3, 4, 5, 6];

const evenNumbers = numbers.filter((num) => num % 2 === 0);

console.log(evenNumbers); // [2, 4, 6]
13 changes: 13 additions & 0 deletions javascript/source/test/filter.object.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const people = [
{ name: "Alice", age: 17 },
{ name: "Bob", age: 20 },
{ name: "Charlie", age: 18 },
];

const adults = people.filter((person) => person.age >= 18);

console.log(adults);
// [
// { name: 'Bob', age: 20 },
// { name: 'Charlie', age: 18 }
// ]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "your-project-name",
"version": "1.0.0",
"scripts": {
"dev": "node javascript/source/printer.js"
"dev": "node javascript/source/printer.js",
"devtest": "node javascript/source/test.js"
},
"author": "Your Name",
"license": "ISC",
Expand Down