Eat Study Love

먹고 공부하고 사랑하라

코테준비 33

Min Cost to Connect All Points(Array,Union Find,Graph,Minimum Spanning Tree)

https://leetcode.com/problems/min-cost-to-connect-all-points/description/You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.Return the minimum cost to make all poin..

Coding_Practice 2024.11.12

Binary Grid Question[Loop & Graph]

list of list[int] 의 data type을 받아서 가장 긴 connected 1's length를 반환하는 함수를 만들어야 한다. Matrix 는 2차원이다보니까 m*n Matrix를 생각하면 되고, 주어진 2차원 Matrix에서 어떤 것을 0에서 1로 바꿀 지 잘 고민해야하고 x, y축 index 헷갈리지 않게 주의해야 한다. 이거때문에 index overflow로 애좀 먹음.. 꿀팁은 python deque만 있으면 queue / stack 다 구현할 수 있다는 것이고, python의 경우 if 문에서 0  그리고 맨 처음 언급했듯이, x / y축 len과 idx following을 잘 해야 한다. 이런 종류의 문제는 무작정 coding에 들어가지 말고, 머릿속으로 또는 빈 종이에 구조를..

Coding_Practice 2024.11.04

MinMaxDivision(Divide array A into K blocks and minimize the largest sum of any block)

https://app.codility.com/programmers/lessons/14-binary_search_algorithm/min_max_division/ MinMaxDivision coding task - Learn to Code - CodilityDivide array A into K blocks and minimize the largest sum of any block.app.codility.comYou are given integers K, M and a non-empty array A consisting of N integers. Every element of the array is not greater than M.You should divide this array into K block..

Coding_Practice 2024.10.16

Sort List[Linked List,Two Pointers,Divide and Conquer,Sorting,Merge Sort]

https://leetcode.com/problems/sort-list/description/Given the head of a linked list, return the list after sorting it in ascending order. Example 1:Input: head = [4,2,1,3]Output: [1,2,3,4]Example 2:Input: head = [-1,5,3,4,0]Output: [-1,0,3,4,5]Example 3:Input: head = []Output: [] Constraints:The number of nodes in the list is in the range [0, 5 * 104].-105  Follow up: Can you sort the linked lis..

Coding_Practice 2024.10.10

Minimum Add to Make Parentheses Valid[M,String,Stack,Greedy]

https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/description/?envType=daily-question&envId=2024-10-09A parentheses string is valid if and only if:It is the empty string,It can be written as AB (A concatenated with B), where A and B are valid strings, orIt can be written as (A), where A is a valid string.You are given a parentheses string s. In one move, you can insert a parent..

Coding_Practice 2024.10.09

Kth Largest Element in a Stream[E,Tree,Design,Binary Search Tree,Heap (Priority Queue),Binary Tree,Data Stream]

https://leetcode.com/problems/kth-largest-element-in-a-stream/description/?envType=daily-question&envId=2024-08-12Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.Implement KthLargest class:KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums.int..

Coding_Practice 2024.08.12