function getDirections(matrix, from, to) { const queue = [from]; // 큐를 초기화하고 시작 정점을 삽입 const visited = new Array(matrix.lengt).fill(false); // 방문 여부를 저장할 배열 while (queue.length > 0) { const node = queue.shift(); // 큐에서 노드를 추출 if (node === to) return true; // 목적지에 도착하면 true 반환 visited[node] = true; // 방문한 노드는 visited 배열에 표시 for (let i = 0; i < matrix[node].length; i++) { if (matrix[node][i] && !v..
const levelOrderTraversal = (root) => { const result = []; // 결과를 저장할 배열 if (!root) return result; // 빈 트리일 경우 빈 배열 반환 const queue = [root]; // 큐를 초기화하고 루트 노드를 삽입 //queue라는 배열을 생성하고, 이진 트리의 루트 노드를 queue 배열에 넣는다. while (queue.length > 0) { const currentLevelSize = queue.length; // 현재 레벨의 크기 저장 const currentLevel = []; // 현재 레벨의 노드를 저장할 배열 for (let i = 0; i < currentLevelSize; i++) { const node = ..
class GraphWithAdjacencyMatrix { constructor() { this.matrix = []; } //이차원 배열(matrix)을 초기화 addVertex() { //버텍스를 추가합니다. const currentLength = this.matrix.length; for (let i = 0; i < currentLength; i++) { this.matrix[i].push(0); } this.matrix.push(new Array(currentLength + 1).fill(0)); //새로운 행(즉, 새로운 정점)을 만들고, 이를 matrix 배열의 끝에 추가 //새로운 정점은 다른 정점과 아직 연결되어 있지 않은 상태 //currentLength + 1 길이의 새로운 배열을 생성..

Tokens 과제 JWT 생성 및 검증을 도와주는 헬퍼 require('dotenv').config(); //dotenv 패키지를 사용하여 환경 변수를 로드 const { sign, verify } = require('jsonwebtoken'); //Node.js 서버에서 JWT(Json Web Token)을 생성하고 검증하는 기능을 구현한 모듈 module.exports = { generateToken: (user, checkedKeepLogin) => { const payload = { id: user.id, email: user.email, }; let result = { accessToken: sign(payload, process.env.ACCESS_SECRET, { expiresIn: '1d'..

cookie 튜토리얼 CORS 설정 CORS 설정은 이러한 Same-Origin Policy를 우회하기 위해 서버에서 브라우저에게 특정 출처에서 자원에 대한 액세스를 허용하도록 허용하는 메커니즘입니다. 이를 통해, 다른 출처의 자원을 안전하게 사용 const corsOptions = { // client는 http://localhost:3000 을 이용 origin: "http://localhost:3000", // cookie는 인증 정보를 포함하는 경우가 많으므로 credentials도 설정 //credentials 속성은 자격 증명 정보를 포함하는 요청을 허용할지 여부를 결정 credentials: true, // 허용할 메소드를 배열에 담아서 작성 methods: ['GET', 'POST', 'O..
chrome에 Screen Reader를 설치 page02 1. 인라인 안에 블록 X 인라인 - a ,em ,strong 블록 div p h1 2. 의미있는 요소 사용하기 b대신 콘텐츠에 의미를 부여하는 strong을 사용하기 i대신 콘텐츠에 의미를 부여하는 em을 사용하기 3. hgrop 마구잡이 X import styled form "styled-cpmponents" const FontSizingDiv = styled.div ` font-size: ${props => props/fontSizing || '1rem'}; font-weight : bold; ` fontSize='1.8rem'>xxxxx 4. const MarginButtonList = styled.div ` margin-bottom : ..