You are given a survey with n questions where each question’s answer is either 0 (no) or 1 (yes). The survey is completed by m students and m mentors. Each student’s answers are represented by a 2D array of size m x n, and similarly, each mentor’s answers are represented by another 2D array. The compatibility score of a student-mentor pair is calculated as the number of answers that are the same for both the student and the mentor. Your task is to find the optimal pairing of students to mentors that maximizes the sum of the compatibility scores.
You are given a game board represented as an 8x8 grid, where each cell can either be free (’.’), white (‘W’), or black (‘B’). The objective is to determine if placing your piece (either ‘W’ or ‘B’) at a specified location will create a valid ‘good line’ where the line consists of three or more cells. A good line is defined as a line (horizontal, vertical, or diagonal) with endpoints of the same color and any cells between them of the opposite color.
You are tasked with designing a dynamic array where the number of elements that should be in the array at each time is provided in an integer array nums. Additionally, you are given an integer k, representing the maximum number of times you can resize the array. At each time step, the array’s size must be large enough to hold the elements in nums[i] and any extra space will be wasted. Your goal is to minimize the total wasted space by resizing the array at most k times.
You are given a string s and an array of strings words. Determine if the string s can be formed by concatenating the first k strings from the array words, for some value of k, where 1 <= k <= words.length. Return true if s is a prefix of words, or false otherwise.
You are given an array of integers piles, where each element represents the number of stones in a pile, and an integer k. You need to perform the following operation exactly k times: Choose any pile, and remove floor(piles[i] / 2) stones from it. You can apply the operation to the same pile multiple times. The goal is to minimize the total number of stones left in all piles after performing the operation k times.
You are given an array nums containing distinct integers. You need to rearrange the elements of the array such that no element is equal to the average of its two adjacent elements. Specifically, for every index i (1 <= i < nums.length - 1), the condition (nums[i-1] + nums[i+1]) / 2 != nums[i] should hold. Your task is to return any valid rearrangement of nums that satisfies this condition.