본문 바로가기

Algorithm

(2139)
(C++) - LeetCode (easy) 566. Reshape the Matrix https://leetcode.com/problems/reshape-the-matrix/description/ Reshape the Matrix - LeetCode Can you solve this real interview question? Reshape the Matrix - In MATLAB, there is a handy function called reshape which can reshape an m x n matrix into a new one with a different size r x c keeping its original data. You are given an m x n matrix mat a leetcode.com 2차원 vector를 다루는 구현 문제였습니다. 📕 풀이방법 📔 ..
(C++) - LeetCode (easy) 563. Binary Tree Tilt https://leetcode.com/problems/binary-tree-tilt/description/ Binary Tree Tilt - LeetCode Can you solve this real interview question? Binary Tree Tilt - Given the root of a binary tree, return the sum of every tree node's tilt. The tilt of a tree node is the absolute difference between the sum of all left subtree node values and all right subtr leetcode.com 자료구조 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 왼쪽과 오른쪽 s..
(C++) - LeetCode (easy) 561. Array Partition https://leetcode.com/problems/array-partition/description/ Array Partition - LeetCode Can you solve this real interview question? Array Partition - Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized sum. leetcode.com 정렬 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1. 오름차순으로 num..
(C++) - LeetCode (easy) 557. Reverse Words in a String III https://leetcode.com/problems/maximum-depth-of-n-ary-tree/description/ Maximum Depth of N-ary Tree - LeetCode Can you solve this real interview question? Maximum Depth of N-ary Tree - 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 seriali leetcode.com 재귀적인 tree 순회로 해결한 ..
(C++) - LeetCode (easy) 557. Reverse Words in a String III https://leetcode.com/problems/reverse-words-in-a-string-iii/description/
(C++) - LeetCode (easy) 551. Student Attendance Record I https://leetcode.com/problems/student-attendance-record-i/description/ Student Attendance Record I - LeetCode Can you solve this real interview question? Student Attendance Record I - You are given a string s representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day. The record only leetcode.com 구현 문제였습니다. 📕 풀이방법 📔..
(C++) - LeetCode (easy) 543. Diameter of Binary Tree https://leetcode.com/problems/diameter-of-binary-tree/description/ Diameter of Binary Tree - LeetCode Can you solve this real interview question? Diameter of Binary Tree - Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path leetcode.com 재귀함수를 이용해 답을 구하는 문제였습니다. 📕..
(C++) - LeetCode (easy) 541. Reverse String II https://leetcode.com/problems/reverse-string-ii/description/ Reverse String II - LeetCode Can you solve this real interview question? Reverse String II - Given a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string. If there are fewer than k characters left, reverse all of them. leetcode.com 문자열을 다루는 문제였습니다. 📕 풀이방법 📔 풀이과정 2*k만큼 증..