All Posts

Leetcode 2570: Merge Two 2D Arrays by Summing Values

You are given two 2D integer arrays nums1 and nums2. Each element in nums1 and nums2 is an array of two integers: an id and a value. The arrays are sorted in ascending order by the id. Your task is to merge the two arrays into a single array, sorted by id. Each id should appear only once, and if an id appears in both arrays, its value should be the sum of the values from both arrays. If an id is present in only one array, its value remains as it is.

Leetcode 2588: Count the Number of Beautiful Subarrays

You are given a 0-indexed integer array nums. In one operation, you can choose two indices and subtract a power of two from both elements at those indices. A subarray is considered beautiful if you can make all of its elements equal to zero by applying the operation any number of times. Your task is to return the number of beautiful subarrays in nums.

Leetcode 2593: Find Score of an Array After Marking All Elements

You are given an array nums consisting of positive integers. Starting with a score = 0, repeatedly select the smallest unmarked integer, add its value to the score, and mark it along with its adjacent elements (if any). Continue this until all elements are marked, then return the final score.

Leetcode 2597: The Number of Beautiful Subsets

You are given an array of positive integers nums and a positive integer k. A subset of nums is considered beautiful if it does not contain any two integers whose absolute difference is equal to k. Your task is to return the number of non-empty beautiful subsets of the array nums. A subset is formed by deleting some (possibly none) elements from nums, and two subsets are different if their selected indices are different.

Leetcode 2598: Smallest Missing Non-negative Integer After Operations

You are given a 0-indexed integer array nums and a positive integer value. In one operation, you can either add or subtract the integer value from any element of the array nums. The MEX (Minimum Excluded Value) of an array is the smallest non-negative integer that does not appear in the array. Your task is to determine the maximum possible MEX of the array nums after performing the mentioned operations any number of times.

Leetcode 2605: Form Smallest Number From Two Digit Arrays

You are given two arrays nums1 and nums2, both containing unique digits. Your task is to find the smallest possible number that contains at least one digit from both arrays. If there are common digits between the two arrays, the smallest common digit will be the answer. If no common digit exists, return the smallest number formed by taking the smallest digit from each array.