You are given two integer arrays, nums1 and nums2, both having length n. You are allowed to perform a series of operations (possibly none). In each operation, you can select an index i in the range [0, n-1] and swap the values of nums1[i] and nums2[i]. The goal is to satisfy two conditions: the last element of nums1 is equal to the maximum value in nums1, and the last element of nums2 is equal to the maximum value in nums2. Return the minimum number of operations required, or -1 if it’s impossible to satisfy both conditions.
You are given a binary string s of length n, where each character represents a ball: ‘1’ for black and ‘0’ for white. The goal is to arrange the balls such that all the white balls are on the left side and all the black balls are on the right side, by swapping two adjacent balls in each step. You need to find the minimum number of adjacent swaps required to achieve this arrangement.
You are given a grid with n + 2 horizontal bars and m + 2 vertical bars, creating 1x1 unit cells. You can remove some bars from the given arrays hBars (horizontal bars) and vBars (vertical bars). The remaining bars are fixed and cannot be removed. Your task is to determine the maximum area of a square-shaped hole that can be formed in the grid after removing some bars.
You are given a list of integers ‘prices’, where each element ‘prices[i]’ represents the cost to purchase the ‘i’-th fruit. If you buy the ‘i’-th fruit at prices[i] coins, you get all subsequent fruits for free. Your task is to determine the minimum number of coins required to purchase all the fruits.
You are given a string s and a positive integer k. A string is beautiful if it satisfies the conditions that the number of vowels equals the number of consonants, and the product of the number of vowels and consonants is divisible by k. Return the number of non-empty beautiful substrings in the string.
You are given a list of integers, nums, and a positive integer limit. In each operation, you can choose two indices i and j and swap the elements at these indices if the absolute difference between nums[i] and nums[j] is less than or equal to the given limit. Your task is to return the lexicographically smallest array that can be obtained after applying the operation as many times as needed.