Eat Study Love

먹고 공부하고 사랑하라

C++ 147

Symmetric Tree[E,Tree,Depth-First Search,Breadth-First Search,Binary Tree]

https://leetcode.com/problems/symmetric-tree/description/Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). Example 1:Input: root = [1,2,2,3,4,4,3]Output: trueExample 2:Input: root = [1,2,2,null,3,null,3]Output: false Constraints:The number of nodes in the tree is in the range [1, 1000].-100  Follow up: Could you solve it both recursively..

Coding_Practice 2024.07.31

Maximum Level Sum of a Binary Tree[M,Tree,Depth-First Search,Breadth-First Search,Binary Tree]

https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on.Return the smallest level x such that the sum of all the values of nodes at level x is maximal. Example 1:Input: root = [1,7,0,7,-8,null,null]Output: 2Explanation: Level 1 sum = 1.Level 2 sum = 7 + 0 = 7.Level 3 sum = 7 + -8 = -1...

Coding_Practice 2024.07.31

Binary Tree Inorder Traversal[E,Stack,Tree,Depth-First Search,Binary Tree]

https://leetcode.com/problems/binary-tree-inorder-traversal/description/Given the root of a binary tree, return the inorder traversal of its nodes' values. Example 1:Input: root = [1,null,2,3]Output: [1,3,2]Example 2:Input: root = []Output: []Example 3:Input: root = [1]Output: [1] Constraints:The number of nodes in the tree is in the range [0, 100].-100 굉장히 기초적인 것이라고 생각했던 부분들인데 모르겠다아 짜증난다.. 1. P..

Coding_Practice 2024.07.31

C++ Container, Custom Map Practice

답안?을 좀 보긴 했지만 그래도 차분히 코드를 짜봤다. 해당과제는 C++의 기본적인 OOP 특성은 물론, Container의 특징까지 잘 파악해볼 수 있는 과제이다. 일단 첫 번째 hw2-1의 경우 나의 코드는 아래와 같소 1. Container 과제//Container.hpp#include #include using namespace std;// Implement definition of all classes and the member functions in this file.class Container{public: float size; float capa; string* code; string str; Container(float s):size(s),code(nullptr..

Coding_Practice 2024.07.29

Convert 1D Array Into 2D Array[E,Array,Matrix,Simulation]

https://leetcode.com/problems/convert-1d-array-into-2d-array/description/You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with  m rows and n columns using all the elements from original.The elements from indices 0 to n - 1 (inclusive) of original should form the first row of the constructed 2D ..

Coding_Practice 2024.07.26

Adding Spaces to a String[M,ArrayTwo Pointers,String,Simulation]

https://leetcode.com/problems/adding-spaces-to-a-string/description/You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index.For example, given s = "EnjoyYourCoffee" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at..

Coding_Practice 2024.07.26