[LeetCode] 3396. Minimum Number of Operations to Make Elements in Array Distinct (Python)
·
알고리즘/LeetCode
난이도: EasyProblem DescriptionYou are given an integer array nums. You need to ensure that the elements in the array are distinct. To achieve this, you can perform the following operation any number of times:Remove 3 elements from the beginning of the array. If the array has fewer than 3 elements, remove all remaining elements.Note that an empty array is considered to have distinct elements. Retur..
[LeetCode] 2873. Maximum Value of an Ordered Triplet I (Python)
·
알고리즘/LeetCode
난이도: EasyProblem DescriptionYou are given a 0-indexed integer array nums. Return the maximum value over all triplets of indices (i, j, k) such that i . If all such triplets have a negative value, return 0. The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k]. Problem ExampleExample 1:Input: nums = [12,6,1,2,7]Output: 77Explanation: The value of the triplet (0, 2,..
[LeetCode] 2140. Solving Questions With Brainpower (Python)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionYou are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri]. The array describes the questions of an exam, where you have to process the questions in order (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question i will earn you pointsi points but you will be unable to solve ea..
[Airflow] PythonOperator를 이용한 DAG 작성 및 실행
·
Data Engineering/Airflow
이번 글에서는 `Apache Airflow`에서 `DAG`를 작성하고 실행하는 방법에 대해 설명하려고 한다. 앞선 글에서 설명했듯이, `Airflow`는 `DAG(Directed Acyclic Graph)`를 이용해 작업의 실행 순서를 정의한다. 간단하게 이러한 `DAG`를 작성해보고 직접 실행해 볼 예정이다. 실습 환경OSUbuntu 20.04Docker28.0.4Apache Airflowairflow:2.10.5 실습은 Ubuntu 20.04 환경에서 진행했으며, Docker Compose를 활용하여 Airflow를 구성하였다.  DAG 작성DAG는 기본적으로 Python으로 작성되며 `dags/` 디렉토리에 작성하면 된다. Airflow는 해당 디렉토리 내의 Python 파일을 자동으로 인식하여 D..
[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..