Eat Study Love

먹고 공부하고 사랑하라

Programming 49

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

Python Binary Tree 문제[Final Test 기출]

문제의 요지와 Skleton code는 아래와 같다."""1. binary tree height 구하라2. binary tree balanced 맞는지 체크3. binary search tree 맞는지 체크4. 두 노드의 common ancestor 모두 구하기5. 두 노드의 lowest common ancestor 구하기"""  일단 문제에 쓰인 저 단어들이 각 무엇을 뜻하는지 부터 체크해보기1. height(T0)트리의 높이 구하기:정의: 트리의 높이는 루트 노드에서 가장 깊은 리프 노드까지의 경로 길이입니다.계산:루트 8의 왼쪽 서브트리의 높이 = 2루트 8의 오른쪽 서브트리의 높이 = 2따라서 전체 높이는 3.2. is_balanced(T0)트리가 균형 잡혔는지 여부:정의: 이진 트리가 균형 잡혔..

Coding_Practice 2024.12.17

Remove loop in Linked List(Linked List,two-pointer,algorithm,Data Structures,Algorithms) - 플로이드의 사이클 감지 알고리즘 (Floyd's Cycle Detection Algorithm)

https://www.geeksforgeeks.org/problems/remove-loop-in-linked-list/1?page=1&category=Linked%20List&difficulty=Medium,Hard&sortBy=submissions Remove loop in Linked List | Practice | GeeksforGeeksGiven the head of a linked list that may contain a loop.  A loop means that the last node of the linked list is connected back to a node in the same list.  So if the next of the previous node is null. then..

Coding_Practice 2024.12.17

Construct String With Repeat Limit(Hash Table,String,Greedy,Heap (Priority Queue)Counting)

https://leetcode.com/problems/construct-string-with-repeat-limit/description/?envType=daily-question&envId=2024-12-17You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to use all characters from s.Return the lexicographically largest repeatLimit..

Coding_Practice 2024.12.17

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

Move Pieces to Obtain a String(Two Pointers,String)

https://leetcode.com/problems/move-pieces-to-obtain-a-string/description/?envType=daily-question&envId=2024-12-05You are given two strings start and target, both of length n. Each string consists only of the characters 'L', 'R', and '_' where:The characters 'L' and 'R' represent pieces, where a piece 'L' can move to the left only if there is a blank space directly to its left, and a piece 'R' ca..

Coding_Practice 2024.12.05

Minesweeper[Array,Depth-First Search,Breadth-First Search,Matrix]

https://leetcode.com/problems/minesweeper/description/Let's play the minesweeper game (Wikipedia, online game)!You are given an m x n char matrix board representing the game board where:'M' represents an unrevealed mine,'E' represents an unrevealed empty square,'B' represents a revealed blank square that has no adjacent mines (i.e., above, below, left, right, and all 4 diagonals),digit ('1' to '..

Coding_Practice 2024.12.04