Eat Study Love

먹고 공부하고 사랑하라

코딩테스트 65

Linked list with Stack Node 문제

이번 문제는 Linked list를 C 코드로 구현하는 것인데, 특이점은 각 Node가 Stack 구조라는 것이다.즉 아래와 같이 Linked list Node가 존재한다는 것!  다시 말하면, 밖에서 봤을 땐 하나의 커다란 Stack인데 이것들이 내부에선 Linked list로 구성이 되어 있다는 것이다.문제의 조건은 아래와 같다.   1. 각 Stack Node에는 Max-capacity가 존재하다. Max-capacity를 넘어서면 새로운 Stack Node를 만든다.   2. list_size() method를 구현하라. 현재 원소가 존재하는 List Node(stack)의 개수를 반환한다.   3. push() method를 구현하라.   4. pop() method를 구현하라. 원소가 Link..

SW 만학도/C 2024.12.23

Minimum Number of Operations to Sort a Binary Tree by Level(Tree,Breadth-First Search,Binary Tree)

https://leetcode.com/problems/minimum-number-of-operations-to-sort-a-binary-tree-by-level/description/?envType=daily-question&envId=2024-12-23You are given the root of a binary tree with unique values.In one operation, you can choose any two nodes at the same level and swap their values.Return the minimum number of operations needed to make the values at each level sorted in a strictly increasin..

Coding_Practice 2024.12.23

Final Array State After K Multiplication Operations I(Array,Math,Heap (Priority Queue),Simulation)

https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i/description/?envType=daily-question&envId=2024-12-16You are given an integer array nums, an integer k, and an integer multiplier.You need to perform k operations on nums. In each operation:Find the minimum value x in nums. If there are multiple occurrences of the minimum value, select the one that appears first.R..

Coding_Practice 2024.12.16

Maximum Difference Between Node and Ancestor(Tree,Depth-First Search,Binary Tree)

https://leetcode.com/problems/maximum-difference-between-node-and-ancestor/description/Given the root of a binary tree, find the maximum value v for which there exist different nodes a and b where v = |a.val - b.val| and a is an ancestor of b.A node a is an ancestor of b if either: any child of a is equal to b or any child of a is an ancestor of b. Example 1:Input: root = [8,3,10,1,6,null,14,nul..

Coding_Practice 2024.11.28

Sort Characters By Frequency(Hash Table,String,Sorting,Heap (Priority Queue),Bucket Sort,Counting)

https://leetcode.com/problems/sort-characters-by-frequency/description/Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string.Return the sorted string. If there are multiple answers, return any of them. Example 1:Input: s = "tree"Output: "eert"Explanation: 'e' appears twice while 'r' and..

Coding_Practice 2024.11.18

Guess Number Higher or Lower II[Math,Dynamic Programming,Game Theory]

https://leetcode.com/problems/guess-number-higher-or-lower-ii/description/We are playing the Guessing Game. The game will work as follows:I pick a number between 1 and n.You guess a number.If you guess the right number, you win the game.If you guess the wrong number, then I will tell you whether the number I picked is higher or lower, and you will continue guessing.Every time you guess a wrong n..

Coding_Practice 2024.11.05

Trapping Rain Water[자주 나오는 물 채우기 DP문제][Array,Two Pointers,Dynamic Programming,Stack,Monotonic Stack]

https://leetcode.com/problems/trapping-rain-water/description/Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1:Input: height = [0,1,0,2,1,0,1,3,2,1,2,1]Output: 6Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rai..

Coding_Practice 2024.11.04

Find Minimum in Rotated Sorted Array2[Array,Binary Search]

https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/description/Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become:[4,5,6,7,0,1,4] if it was rotated 4 times.[0,1,4,4,5,6,7] if it was rotated 7 times.Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the ..

Coding_Practice 2024.10.31