[LeetCode] 2523. Closest Prime Numbers in Range (Python)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionGiven two positive integers left and right, find the two integers num1 and num2 such that:left .Both num1 and num2 are prime numbers.num2 - num1 is the minimum amongst all other pairs satisfying the above conditions.Return the positive integer array ans = [num1, num2]. If there are multiple pairs satisfying these conditions, return the one with the smallest num1 val..
[LeetCode] 2965. Find Missing and Repeated Values (Python)
·
알고리즘/LeetCode
난이도: EasyProblem DescriptionYou are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twice and b which is missing. The task is to find the repeating and missing numbers a and b. Return a 0-indexed integer array ans of size 2 where ans[0] equals to a and ans[1] equals to b. Problem ExampleExample 1:In..
[LeetCode] 2579. Count Total Number of Colored Cells (Python)
·
알고리즘/LeetCode
난이도: MediumProblem Description There exists an infinitely large two-dimensional grid of uncolored unit cells. You are given a positive integer n, indicating that you must do the following routine for n minutes:At the first minute, color any arbitrary unit cell blue.Every minute thereafter, color blue every uncolored cell that touches a blue cell.Below is a pictorial representation of the state o..
[LeetCode] 1780. Check if Number is a Sum of Powers of Three (Python)
·
알고리즘/LeetCode
난이도: MediumProblem Description Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false. An integer y is a power of three if there exists an integer x such that y == 3x. Problem ExampleExample 1:Input: n = 12Output: trueExplanation: 12 = 3^1 + 3^2Example 2:Input: n = 91Output: trueExplanation: 91 = 3^0 + 3^2 + 3^4Example 3:I..
[LeetCode] 2161. Partition Array According to Given Pivot (Python)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionYou are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:Every element less than pivot appears before every element greater than pivot.Every element equal to pivot appears in between the elements less than and greater than pivot.The relative order of the elements less than pivot and the elemen..
[LeetCode] 2570. Merge Two 2D Arrays by Summing Values (Python)
·
알고리즘/LeetCode
난이도: EasyProblem DescriptionYou are given two 2D integer arrays nums1 and nums2.nums1[i] = [idi, vali] indicate that the number with the id idi has a value equal to vali.nums2[i] = [idi, vali] indicate that the number with the id idi has a value equal to vali.Each array contains unique ids and is sorted in ascending order by id. Merge the two arrays into one array that is sorted in ascending ord..