본문 바로가기

Algorithm/알고리즘 문제풀이92

LeetCode 101(Symmetric Tree, java) 0. 문제 https://leetcode.com/problems/symmetric-tree/ Symmetric Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 해당 이진트리의 모든 노드가 가진 값을 탐색 및 비교하여 대칭하는지를 판단하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 최초에 루트 노드가 가진 좌/우측 자식은 1개씩이므로, 이 둘의 value를 비교하면 대칭.. 2022. 4. 20.
LeetCode 104(Maximum Depth of Binary Tree, java) 0. 문제 https://leetcode.com/problems/maximum-depth-of-binary-tree/ Maximum Depth of Binary Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 이 이진트리를 탐색하여 이진트리의 깊이를 반환하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 이 문제는 이전에 풀어본 102번 문제에서 사용한 깊이 단위 탐색을 .. 2022. 4. 20.
LeetCode 102(Binary Tree Level Order Traversal, java) 0. 문제 https://leetcode.com/problems/binary-tree-level-order-traversal/ Binary Tree Level Order Traversal - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 이진트리(root)를 깊이 단위로 탐색하며, 동일한 깊이에 있는 모든 노드를 하나의 배열로 묶는다. - 이렇게 깊이 단위로 묶인 각 배열을 하나의 배열 안에 넣어 .. 2022. 4. 19.
LeetCode 145(Binary Tree Postorder Traversal, java) 0. 문제 https://leetcode.com/problems/binary-tree-postorder-traversal/ Binary Tree Postorder Traversal - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 해당 이진트리를 후위 순회 방식으로 탐색하여, 탐색한 순서대로 노드의 값을 배열에 담아 반환하는 것이 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 후위 순회는 좌측 .. 2022. 4. 19.
LeetCode 94(Binary Tree In-order Traversal, java) 0. 문제 https://leetcode.com/problems/binary-tree-inorder-traversal/ Binary Tree Inorder Traversal - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 주어진 이진트리를 중위 순회 순서로 탐색하여, 방문한 노드의 값을 배열에 담아 반환하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 중위 순회는 좌측 자식.. 2022. 4. 19.
LeetCode 144(Binary Tree Preorder Traversal, java) 0. 문제 https://leetcode.com/problems/binary-tree-preorder-traversal/ Binary Tree Preorder Traversal - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 이 문제는 이진트리를 전위 순회(Preorder)로 탐색하여 방문한 노드를 리스트로 반환하는 것이 핵심이다. - 이진 트리를 탐색하는 방법에는 3가지가 있다. → 전위 순회(.. 2022. 4. 18.
LeetCode 232(Implement Queue using Stacks, java) 0. 문제 https://leetcode.com/problems/implement-queue-using-stacks/ Implement Queue using Stacks - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 이 문제는 Stack 자료구조 2개를 이용하여 Queue를 구현하는 것이 핵심이다. - Stack 자료구조 2개를 이용하여 Queue의 메서드를 모두 구현해야 한다. 2. 문제 해설 a) 첫 번째 접근 - 가장 근본적인 원리를.. 2022. 4. 18.
LeetCode 20(Valid Parentheses, java) 0. 문제 https://leetcode.com/problems/valid-parentheses/ Valid Parentheses - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 문자열(s)이 주어진다. - 문자열(s)은 괄호(), 중괄호{}, 대괄호[]로 이루어진다. - 문자열 내부의 괄호가 순서대로 짝에 맞게 열리고 닫히는지를 파악하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 괄호의 순서와 짝을 파악하는 것.. 2022. 4. 18.
LeetCode 83(Remove Duplicates from Sorted List, java) 0. 문제 https://leetcode.com/problems/remove-duplicates-from-sorted-list/ Remove Duplicates from Sorted List - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 오름차순으로 정렬된 연결 리스트(head)가 주어진다. - 해당 연결 리스트 내부에는 중복된 value를 가진 노드가 존재한다. - 각 value가 한 번씩만 사용되도록 중복된 value를 가진 .. 2022. 4. 17.