[LeetCode] 2780. Minimum Index of a Valid Split (Python)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionAn element x of an integer array arr of length m is dominant if more than half the elements of arr have a value of x. You are given a 0-indexed integer array nums of length n with one dominant element. You can split nums at an index i into two arrays nums[0, ..., i] and nums[i + 1, ..., n - 1], but the split is only valid if:0 nums[0, ..., i], and nums[i + 1, ..., n..
[LeetCode] 2033. Minimum Operations to Make a Uni-Value Grid (Python)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionYou are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid. A uni-value grid is a grid where all the elements of it are equal. Return the minimum number of operations to make the grid uni-value. If it is not possible, return -1.  Problem ExampleExample 1:Input: grid = [[2,4],[6,8]], x..
[LeetCode] 3394. Check if Grid can be Cut into Sections (Python)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionYou are given an integer n representing the dimensions of an n x n grid, with the origin at the bottom-left corner of the grid. You are also given a 2D array of coordinates rectangles, where rectangles[i] is in the form [startx, starty, endx, endy], representing a rectangle on the grid. Each rectangle is defined as follows:(startx, starty): The bottom-left corner of..
[LeetCode] 3169. Count Days Without Meetings (Python)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionYou are given a positive integer days representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array meetings of size n where, meetings[i] = [start_i, end_i] represents the starting and ending days of meeting i (inclusive). Return the count of days when the employee is available for work but no meetings a..
[LeetCode] 1976. Number of Ways to Arrive at Destination (Python)
·
알고리즘/LeetCode
난이도: MediumProblem Description You are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there is at most one road between any two intersections. You are given an integer n and a 2D integer array roads where roads[i] = [ui,..
25.03.21 코딩테스트 대비
·
알고리즘/코딩테스트 대비
BOJ 16236. 아기 상어https://www.acmicpc.net/problem/16236 내 코드import sysfrom collections import dequeinput = sys.stdin.readlinen = int(input())area = []for i in range(n): area.append(list(map(int, input().split()))) for j in range(n): if area[i][j] == 9: start = (i, j) area[i][j] = 0def bfs(start, size): visited = [[0]*n for _ in range(n)] q = deque([start]) ..