전체 글
-
[LeetCode] 226. Invert Binary Tree c++Coding Test/LeetCode 2022. 12. 19. 19:37
문제 Given the root of a binary tree, invert the tree, and return its root. Input: root = [4,2,7,1,3,6,9] Output: [4,7,2,9,6,3,1] 부모 노드를 기준으로 자식 노드의 좌우 대칭을 바꾸는 문제입니다. 문제 해결 class Solution { public: TreeNode* invertTree(TreeNode* root) { if (!root) return root; swap(root->left, root->right); invertTree(root->left); invertTree(root->right); return root; } }; swap()함수는 algorithm에 내장된 STL함수입니다. swap()..
-
[LeetCode] 1022. Sum of Root To Leaf Binary Numbers c++Coding Test/LeetCode 2022. 12. 19. 18:58
문제 You are given the root of a binary tree where each node has a value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit. For example, if the path is 0 -> 1 -> 1 -> 0 -> 1, then this could represent 01101 in binary, which is 13. For all leaves in the tree, consider the numbers represented by the path from the root to that leaf. Return the sum of the..
-
[C++] 비트 연산, Bitwise ( 10진수를 2진수로 변환)Programming/c++ 2022. 12. 13. 19:43
비트 연산을 이용해서 쉽게 10진수를 2진수로 변환할 수 있다. int main(){ int num = 52; for(int i = 7; i>= 0; i--){ //2진수 표현 자릿수, 자릿수는 늘려도 된다. int result = num >> i & 1; printf_s("%d", result); //00110100 } return 0; } ( num >> i ) : i 자릿수 만큼 오른쪽으로 shift 연산을 실행한다. ( i & 1 ) : 2^0 자릿수를 추출하기 위한 AND연산이다. 52(10진수) 를 2진수로 변환하면 00110100(2진수) 로 변환된다. 곱하기, 나머지 계산을 이용해서 비트 연산을 하지 않아도 위의 비트 연산을 이용하면 더 간단하게 식을 구현할 수 있다.
-
[pug] pug 템플릿 엔진카테고리 없음 2022. 12. 8. 19:59
html보다 간결한 문법과 기능을 가진 pug가 궁금하여 찾아보고 정리한 내용입니다~ PUG 란? (구) Jade , 이름의 라이선스 문제로 Pug로 강제 개명된 이력이 있습니다. Pug는 Express가 지원하는 템플릿 뷰 엔진 중 하나입니다. 파일을 렌더링하여 html로 변환한 후 내부의 javascript를 실행하여 텍스트로 바꾼 후 유저 UI를 형성합니다. Pug로 코드를 작성할 때에는 들여쓰기에 주의해야 합니다. 들여쓸수록 하위 태그 됩니다. 일정한 간격을 유지해야 합니다. 규칙 - 소문자 - 속성은 괄호 - 닫는 태그 없음 - 자식 태그는 부모와 2칸 띄어쓰기 or tab 3가지 장점 1. 상속( block & extends) 뼈대가 될 레이아웃 안에 block만 생성해주고 이를 상속받은 후 ..
-
[javascript] vscode node.js 설치Programming 2022. 12. 8. 19:32
visual studio code에 node.js 개발 환경으로 설정하는 방법을 포스팅하겠습니다~ 1. Node.js 설치 2. vscode 설정 3. 서버 실행 1. Node.js 설치 node.js설치 파일을 다운로드합니다. https://nodejs.org/ko/ Node.js Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. nodejs.org dafualt설정 값으로 모두 next를 눌러 설치를 완료합니다. 2. vscode 설정 (1) js 빌드 확인 vscode 에서 test1.js파일을 만들고 빌드가 되는지 간단하게 확인합니다. var number1 = 10; console.log(number1); 출력이 된다..
-
[Github] github blog 테마에 utterances 연동Github 2022. 12. 8. 10:09
블로그 댓글을 github와 연동되어 관리할 수 있는 "utteracnes" 기능 설치를 포스팅하겠습니다~ 설치하기에 앞서, 크게 utteracnes 기능 연동하는 방법 2가지를 알려드리겠습니다. ⓐ github blog repository에 연동 ⓑ repository 새로 생성하여 연동 (blog repo와 따로 관리) 1. utterances 설치를 위해 홈페이지에서 install 버튼을 누릅니다. github.com/apps/utterances GitHub: Let’s build from here GitHub is where over 94 million developers shape the future of software, together. Contribute to the open source ..