You are given two arrays arr1 and arr2 containing positive integers. Your task is to find the length of the longest common prefix between all pairs of integers (x, y) such that x belongs to arr1 and y belongs to arr2. A prefix of a number is any integer formed by one or more digits starting from its leftmost digit. For example, 123 is a prefix of 12345, but 234 is not. If no common prefix exists for any pair, return 0.
You are given a matrix of integers, where each cell contains a digit from 1 to 9. Starting from any cell in the matrix, you can move in one of eight possible directions (east, south-east, south, south-west, west, north-west, north, and north-east) and create numbers by appending the digits along the path. For each valid path, numbers greater than 10 are generated. The task is to find the most frequent prime number greater than 10 among all the numbers generated by traversing the matrix. If there are multiple such prime numbers, return the largest one. If no prime number exists, return -1.
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 binary array nums. A subarray is called alternating if no two adjacent elements in the subarray have the same value. Return the total number of alternating subarrays in the given binary array.
You are given a 2D matrix grid of size m x n. In one operation, you can change the value of any cell to any non-negative number. Your task is to perform operations such that each cell is equal to the cell below it, and different from the cell to its right. Return the minimum number of operations needed to achieve these conditions.
You are given a 3x3 matrix consisting of characters ‘B’ (black) and ‘W’ (white). Your task is to determine if it is possible to change the color of at most one cell to form a 2x2 square where all cells are of the same color. Return true if it is possible, otherwise return false.