[LeetCode] 2661. First Completely Painted Row or Column (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given a 0-indexed integer array arr, and an m x n integer matrix mat. arr and mat both contain all the integers in the range [1, m * n]. Go through each index i in arr starting from index 0 and paint the cell in mat containing the integer arr[i]. Return the smallest index i at which either a row or a column will be completely painted in mat. 문제 예제Example 1:Input: arr = [..
[LeetCode] 407. Trapping Rain Water II (Python)
·
알고리즘/LeetCode
문제 설명Given an m x n integer matrix heightMap representing the height of each unit cell in a 2D elevation map, return the volume of water it can trap after raining. 문제 예제Example 1:Input: heightMap = [[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]]Output: 4Explanation: After the rain, water is trapped between the blocks.We have two small ponds 1 and 3 units trapped.The total volume of water trapped is ..
[LeetCode] 1368. Minimum Cost to Make at Least One Valid Path in a Grid (Python)
·
알고리즘/LeetCode
난이도: Hard문제 설명Given an m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i][j] can be:1 which means go to the cell to the right. (i.e go from grid[i][j] to grid[i][j + 1])2 which means go to the cell to the left. (i.e go from grid[i][j] to grid[i][j - 1])3 which means go to the lower cell. (i.e go from grid..
[LeetCode] 2683. Neighboring Bitwise XOR (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명A 0-indexed array derived with length n is derived by computing the bitwise XOR (⊕) of adjacent values in a binary array original of length n. Specifically, for each index i in the range [0, n - 1]:If i = n - 1, then derived[i] = original[i] ⊕ original[0].Otherwise, derived[i] = original[i] ⊕ original[i + 1].Given an array derived, your task is to determine whether there exists ..
[LeetCode] 2425. Bitwise XOR of All Pairings (Python)
·
알고리즘/LeetCode
난이도: Medium문제 설명You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers. There exists another array, nums3, which contains the bitwise XOR of all pairings of integers between nums1 and nums2 (every integer in nums1 is paired with every integer in nums2 exactly once). Return the bitwise XOR of all integers in nums3. 문제 예제Example 1:Input: nums1 = [2,1,3], nums2 = [..
[LeetCode] 2429. Minimize XOR (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명Given two positive integers num1 and num2, find the positive integer x such that:x has the same number of set bits as num2, andThe value x XOR num1 is minimal.Note that XOR is the bitwise XOR operation. Return the integer x. The test cases are generated such that x is uniquely determined. The number of set bits of an integer is the number of 1's in its binary representation. 문제 ..