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.
You are given an integer n, representing an array of n elements where all elements are initially set to 0 (uncolored). You are also given a 2D integer array queries, where each query specifies an index and a color. For each query, set the element at the specified index to the given color and then count the number of adjacent pairs of elements in the array that have the same color. Return an array answer where each element corresponds to the number of adjacent pairs with the same color after applying the corresponding query.
You are given a perfect binary tree with n nodes, where each node has a cost associated with it. The tree is numbered from 1 to n, with node 1 as the root. For each node i, its left child is 2*i and its right child is 2*i + 1. You are allowed to increment the cost of any node by 1 any number of times. Your task is to return the minimum number of increments required to make the total cost of the path from the root to each leaf node equal.
You are given a perfect binary tree with n nodes, where each node has a cost associated with it. The tree is numbered from 1 to n, with node 1 as the root. For each node i, its left child is 2*i and its right child is 2*i + 1. You are allowed to increment the cost of any node by 1 any number of times. Your task is to return the minimum number of increments required to make the total cost of the path from the root to each leaf node equal.
You are given a 2D array nums where each row represents a set of numbers. You perform operations on the matrix by removing the largest number from each row at each step. After removing the largest number from each row, you identify the highest number amongst all those removed and add it to your score. Repeat this until the matrix becomes empty and return the final score.