You are given an integer array ’nums’ of even length. Your task is to determine whether it is possible to divide the array into two subarrays, ’nums1’ and ’nums2’, such that both subarrays have distinct elements and the same length. Each subarray must contain half of the total elements from the original array.
You are given a string s consisting of lowercase English letters and question marks (?). Your task is to replace all occurrences of ? with any lowercase English letter in such a way that the total cost of the resulting string is minimized. The cost of a string is the sum of how many times each character has appeared before its current position. If there are multiple solutions with the same minimal cost, return the lexicographically smallest one.
You are given a string word. A letter is considered special if it appears both in its lowercase and uppercase form in the string. Return the number of special letters in word.
You are given a string word. A letter c is called special if it appears both in lowercase and uppercase in word, and every lowercase occurrence of c appears before the first uppercase occurrence of c. Return the number of special letters in word.
You are given a 2D binary matrix grid, where each element is either 0 or 1. A collection of three elements of the grid is considered a right triangle if one element lies in the same row as another and in the same column as the third. The three elements must not be adjacent to each other. Your task is to count the number of right triangles that can be formed where all three elements have a value of 1.
You are given a string word of length n, and an integer k such that k divides n. In one operation, you can pick any two indices i and j, both divisible by k, and swap the substrings starting from i and j, each of length k. The goal is to transform word into a k-periodic string, meaning that the string can be represented as multiple concatenations of a substring of length k. Your task is to determine the minimum number of operations required to make the string k-periodic.