본문 바로가기

알고리즘연구소👨‍💻/리트코드

(21)
[Leetcode 2924번 문제] 2924. Find Champion II 문제 상황There are n teams numbered from 0 to n - 1 in a tournament; each team is also a node in a DAG.You are given the integer n and a 0-indexed 2D integer array edges of length m representing the DAG, where edges[i] = [ui, vi] indicates that there is a directed edge from team ui to team vi in the graph.A directed edge from a to b in the graph means that team a is stronger than team b and team b i..
1213. Intersection of Three Sorted Arrays 문제 상황Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, return a sorted array of only the integers that appeared in all three arrays.3개의 배열이 주어지고 배열은 정렬돼있다 이 배열에서 공통적으로 드러나는 모든 요소들을 정렬된 방향으로 리턴해라입력1 1 출력3개의 배열에 공통적으로 드러나는 모든 요소들을 정렬해놓은 배열과정일단 모든 요소들이 공통으로 등장한다는 점을 인덱스로 치환한다.배열이 정렬돼있기 때문에 인덱스 a, b, c의 값들이 일치하면 이들은 같은값이고 인덱스를 한번에 올린다아닐경우에는 가장 작은 값을 찾아서 그값 인덱스만 올린다...
[Leetcode 1975번 문제] 1975. Maximum Matrix Sum 문제 상황You are given an n x n integer matrix. You can do the following operation any number of times:Choose any two adjacent elements of matrix and multiply each of them by 1.Two elements are considered adjacent if and only if they share a border.Your goal is to maximize the summation of the matrix's elements. Return the maximum sum of the matrix's elements using the operation mentioned above.m * ..
[Leetcode 1861번 문제] 1861. Rotating the Box 문제 상황You are given an m x n matrix of characters box representing a side-view of a box. Each cell of the box is one of the following:A stone '#'A stationary obstacle '*'Empty '.'The box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on an obstacle, another stone, or the bottom of the box. Gravity does not affect the obstac..
[Leetcode 1072번 문제] 1072. Flip Columns For Maximum Number of Equal Rows 문제 상황You are given an m x n binary matrix matrix.You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from 0 to 1 or vice versa).Return the maximum number of rows that have all values equal after some number of flips.m * n의 매트릭스가 있고, 몇개의 열들이 있고, 한 열의 모든 요소들을 뒤집을 수도 있다. 최대의 number of rows를 구해라.all values equal after some number ..
[Leetcode 2257번 문제] 2257. Count Unguarded Cells in the Grid 문제 상황You are given two integers m and n representing a 0-indexed m x n grid. You are also given two 2D integer arrays guards and walls where guards[i] = [rowi, coli] and walls[j] = [rowj, colj] represent the positions of the ith guard and jth wall respectively.A guard can see every cell in the four cardinal directions (north, east, south, or west) starting from their position unless obstructed b..
[Leetcode 2516번 문제] 2516. Take K of Each Character From Left and Right 문제 상황You are given a string s consisting of the characters 'a', 'b', and 'c' and a non-negative integer k. Each minute, you may take either the leftmost character of s, or the rightmost character of s.Return the minimum number of minutes needed for you to take at least k of each character, or return -1 if it is not possible to take k of each character.characters a, b, c로 이루어져있고, 음이아닌 정수 k가 있다. 매..
[Leetcode 862번 문제] 862. Shortest Subarray with Sum at Least K 문제 상황Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return -1.A subarray is a contiguous part of an array.nums와 k가 주어진다. 가장 작은 길이의 비어있지 않은 subarray를 내라. 그 subarray는 합이 k다. 없으면 -1을 리턴해라.입력1 105 1 출력과정순서가 유지되는 subarray를 리턴해야하고 input값은 음수를 끼고있는 배열,음수는 정렬의 적이다. 원래같으면 그냥 바로 누적값으로 정렬할 수 ..