Eat Study Love

먹고 공부하고 사랑하라

코딩 57

Make Lexicographically Smallest Array by Swapping Elements(Array,Union Find,Sorting)

https://leetcode.com/problems/make-lexicographically-smallest-array-by-swapping-elements/description/?envType=daily-question&envId=2025-01-25You are given a 0-indexed array of positive integers nums and a positive integer limit.In one operation, you can choose any two indices i and j and swap nums[i] and nums[j] if |nums[i] - nums[j]| Return the lexicographically smallest array that can be obtai..

Coding_Practice 2025.01.25

Longest Palindrome Substring [Final 기출]

사실 Palindrome 문제는 유형도 많고, DP를 이용해서 풀면 편하지만 너~무 짜친다. 아오 하기 싫어! Longest Palindrome Substring(이하 LPS) 문제를 2개 풀게 됐는데, 하나는 10초컷 / 하나는 30분을 고민해도 어렵다.. 쉬운 문제는 아래와 같다.def is_palindromic(s: str) -> bool: """ > input 's' - A string consisting of only lowercase English letters (1 return a boolean """ # WRITE YOUR CODE HERE n = len(s) left = 0 right = n-1 while left  그냥 input에 대해..

Coding_Practice 2025.01.07

Unique Binary Search Trees(Math,Dynamic Programming,Tree,Binary Search Tree,Binary Tree)

https://leetcode.com/problems/unique-binary-search-trees/description/Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n. Example 1:Input: n = 3Output: 5Example 2:Input: n = 1Output: 1 Constraints:1 그래도 가볍게나마 BST문제도 풀어봐야지..! Linked List , Tree 이런 걸 자꾸만 건들자 근데 이건,, Tree 문제라기보단 수학 문제 같다.. 흐음..  1. Python 일단..

Coding_Practice 2025.01.06

Find Minimum Diameter After Merging Two Trees(Tree,Depth-First Search,Breadth-First Search,Graph)

https://leetcode.com/problems/find-minimum-diameter-after-merging-two-trees/description/?envType=daily-question&envId=2024-12-24There exist two undirected trees with n and m nodes, numbered from 0 to n - 1 and from 0 to m - 1, respectively. You are given two 2D integer arrays edges1 and edges2 of lengths n - 1 and m - 1, respectively, where edges1[i] = [ai, bi] indicates that there is an edge be..

Coding_Practice 2024.12.24

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

Next Greater Element I(Array,Hash Table,Stack,Monotonic Stack)

https://leetcode.com/problems/next-greater-element-i/description/The next greater element of some element x in an array is the first greater element that is to the right of x in the same array.You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2.For each 0  j such that nums1[i] == nums2[j] and determine the next greater element of nums2[j] in nums..

Coding_Practice 2024.12.03