전체 글
-
[LeetCode] 463. Island Perimeter c++Coding Test/LeetCode 2022. 12. 22. 12:56
문제 You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells). The island doesn't have "lakes", meaning the water inside isn't connected to the water a..
-
[vscode] Settings Sync 확장 플러그인 설치 및 설정Programming 2022. 12. 22. 10:44
다른 PC에서도 쉽게 vscode 세팅 정보를 동기화할 수 있는 플러그인 "Settings Sync" 를 설치 및 설정하는 방법을 포스팅하겠습니다~ vscode extensions에서 settings sync를 검색하고 install을 클릭합니다. 설치가 완료되면 welcome페이지가 나옵니다. "Login with Github"를 클릭하여 Github와 연동할 수 있도록 로그인 인증을 합니다. "Edit Configuration" 버튼을 클릭하면 Environment settings, Gloval Settings가 나옵니다. Global Settings에서 Access Token으로 자동으로 생성된 것을 확인 할 수 있습니다. Gist ID를 입력하기 위해 url : gist.github.com/[us..
-
[LeetCode] 559. Maximum Depth of N-ary Tree c++Coding Test/LeetCode 2022. 12. 20. 17:55
문제 Given a n-ary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples). Input: root = [1,null,2,3,4,5,null,null,6,7,null,8,null,9,10,null,null,11,null,12,null,13..
-
[LeetCode] 637. Average of Levels in Binary Tree c++Coding Test/LeetCode 2022. 12. 20. 14:52
문제 Given the root of a binary tree, return the average value of the nodes on each level in the form of an array. Answers within 10^-5 of the actual answer will be accepted. Input: root = [3,9,20,null,null,15,7] Output: [3.00000,14.50000,11.00000] Explanation: The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 is 11. Hence return [3, 14.5, 11]. 같은 depth에 있는 node들의 평균 값..
-
[LeetCode] 104. Maximum Depth of Binary Tree c++Coding Test/LeetCode 2022. 12. 20. 12:06
문제 Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Input: root = [3,9,20,null,null,15,7] Output: 3 트리의 maximum depth를 구하는 문제이다. 문제 해결 int maxDepth(TreeNode* root) { if (!root) { return 0; } int maxLeft = maxDepth(root->left); int maxRight = maxDepth(root->righ..
-
[LeetCode] 94. Binary Tree Inorder Traversal c++Coding Test/LeetCode 2022. 12. 19. 21:36
문제 Given the root of a binary tree, return the inorder traversal of its nodes' values. Input: root = [1,null,2,3] Output: [1,3,2] 트리 순회 알고리즘 중 중위 순회(Inorder Traversal) 를 사용하여 방문한 순서대로 노드 값을 출력하는 문제이다. Inorder Traversal(중위 순회) 란? (left, v); v.push_back(root->val); visitInorder(root->right, v); } } vector inorderTraversal(TreeNode* root) { vector v; visitInorder(root, v); return v; } 다른 방법 class S..