You are given a list of integers arr and a 2D matrix mat. The list arr contains all the integers from the range [1, m * n] and represents the order in which you paint the cells of mat. Each integer in arr corresponds to a cell in mat that is being painted. The goal is to find the smallest index i at which either a row or a column becomes completely painted.
You are given a 0-indexed integer array nums of length n. Your task is to compute the ‘distinct difference array’ of nums. The distinct difference array, diff, is defined such that diff[i] equals the difference between the number of distinct elements in the prefix nums[0,...,i] and the number of distinct elements in the suffix nums[i+1,...,n-1]. Specifically, for each index i, compute diff[i] = distinct elements in the prefix - distinct elements in the suffix.
In this game, there are n friends sitting in a circle, numbered from 1 to n. The game starts with the 1st friend receiving a ball. The ball is passed to a friend k steps away in a clockwise direction, and then on each subsequent turn, the ball is passed to the friend i * k steps away, where i is the turn number (starting from 1). The game ends when any friend receives the ball for the second time. The friends who never receive the ball are considered the losers. The task is to return the list of losers in ascending order.
You are given a string and a list of words. Your task is to break the string into one or more non-overlapping substrings such that each substring is a word from the given list. However, some characters of the string may not be used in any substring. Your goal is to minimize the number of unused characters.
Given a 2D grid of size m x n, you are tasked with finding a new matrix where each cell value is the absolute difference between the count of distinct values in the diagonal cells to the left and above it, and the count of distinct values in the diagonal cells to the right and below it.
You are given a string s. You can perform two types of operations: (1) Choose an index i and remove the closest occurrence of the character at i to the left of i. (2) Choose an index i and remove the closest occurrence of the character at i to the right of i. Minimize the length of the string s by performing these operations and return the final minimized length.