All Posts
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.
Leetcode 2606: Find the Substring With Maximum Cost
You are given a string s, a string chars of distinct characters, and an integer array vals of the same length as chars. The value of each character is determined by either its position in the alphabet or a corresponding value in the vals array if it is present in chars. The cost of a substring is the sum of the values of each character in that substring. Your goal is to find the maximum cost of any substring of s.
Leetcode 2607: Make K-Subarray Sums Equal
You are given a circular integer array arr and an integer k. In this circular array, the first element follows after the last one, and the last element precedes the first one. Your task is to determine the minimum number of operations required to make the sum of every subarray of length k equal. In each operation, you can pick any element in the array and either increase or decrease it by 1.
Leetcode 2610: Convert an Array Into a 2D Array With Conditions
Given an integer array, your task is to create a 2D array from the input array satisfying the following conditions:
- The 2D array should contain all the elements of the input array.
- Each row of the 2D array should contain distinct integers.
- The number of rows in the 2D array should be minimal. Return the resulting array. If there are multiple valid answers, return any of them.