[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] 1122. Relative Sort Array (Python)
·
알고리즘/LeetCode
난이도: Easy 문제 설명Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2. Elements that do not appear in arr2 should be placed at the end of arr1 in ascending order. 문제 예제Example 1:Input: arr1 = [2,3,1,3,2,4,6,7,9,2,19], arr2 = [2,1,4,3,9,6]Output..
[Programmers] 테이블 해시 함수 - Python
·
알고리즘/프로그래머스
난이도: Lv. 2 문제 설명완호가 관리하는 어떤 데이터베이스의 한 테이블은 모두 정수 타입인 컬럼들로 이루어져 있습니다. 테이블은 2차원 행렬로 표현할 수 있으며 열은 컬럼을 나타내고, 행은 튜플을 나타냅니다.첫 번째 컬럼은 기본키로서 모든 튜플에 대해 그 값이 중복되지 않도록 보장됩니다. 완호는 이 테이블에 대한 해시 함수를 다음과 같이 정의하였습니다.해시 함수는 col, row_begin, row_end을 입력으로 받습니다.테이블의 튜플을 col번째 컬럼의 값을 기준으로 오름차순 정렬을 하되, 만약 그 값이 동일하면 기본키인 첫 번째 컬럼의 값을 기준으로 내림차순 정렬합니다.정렬된 데이터에서 S_i를 i 번째 행의 튜플에 대해 각 컬럼의 값을 i 로 나눈 나머지들의 합으로 정의합니다.row_begi..
[LeetCode] 2070. Most Beautiful Item for Each Query - Python
·
알고리즘/LeetCode
문제 설명You are given a 2D integer array items where items[i] = [$price_i$, $beauty_i$] denotes the price and beauty of an item respectively. You are also given a 0-indexed integer array queries. For each queries[j], you want to determine the maximum beauty of an item whose price is less than or equal to queries[j]. If no such item exists, then the answer to this query is 0. Return an array answer ..