Eat Study Love

먹고 공부하고 사랑하라

Programming 51

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

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

The K Weakest Rows in a Matrix(Array,Binary Search,Sorting,Heap (Priority Queue),Matrix)

https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix/description/You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row.A row i is weaker than a row j if one of the following is true:The number of soldiers in row..

Coding_Practice 2024.11.28

Car Pooling(Array,Sorting,Heap (Priority Queue),Simulation,Prefix Sum)

https://leetcode.com/problems/car-pooling/description/There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).You are given the integer capacity and an array trips where trips[i] = [numPassengersi, fromi, toi] indicates that the ith trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi ..

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

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

Is Graph Bipartite?[Depth-First Search,Breadth-First Search,Union Find,Graph]

https://leetcode.com/problems/is-graph-bipartite/description/?envType=problem-list-v2&envId=graphThere is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More formally, for each v in graph[u], there is an undirected edge between node u and node v. The graph has the f..

Coding_Practice 2024.10.28