A company is planning to interview 2n people, and for each person, there are two possible cities where they can be interviewed. The cost of flying a person to city A or city B is given. You need to find the minimum cost to fly exactly n people to each city. The challenge is to select n people for city A and the remaining n people for city B such that the total cost is minimized.
You are given an array of integers nums and two integers firstLen and secondLen. Your task is to find the maximum sum of elements from two non-overlapping subarrays of lengths firstLen and secondLen. The subarrays can appear in any order, but they must not overlap.
You are given three stones located at different positions on the X-axis. The positions are represented by three distinct integers a, b, and c. In one move, you can pick a stone from either of the two endpoints (the smallest or the largest position) and move it to any unoccupied position between the two endpoints. The game ends when all three stones are positioned at three consecutive spots on the X-axis. Your task is to determine the minimum and maximum number of moves required to reach this configuration.
You are given an m x n grid of integers where each value represents the color of a cell. You are also given three integers: row, col, and color. The task is to change the color of the border of the connected component containing the cell at grid[row][col]. A connected component is defined as a group of adjacent cells that have the same color. A border cell is a cell that is either adjacent to a different color cell or is on the boundary of the grid. You should return the updated grid where the border of the connected component is colored with the specified color.
Given two integer arrays, nums1 and nums2, we write the integers of both arrays on two separate horizontal lines. We can draw connecting lines between the elements of nums1 and nums2 if they are equal and the lines do not intersect. The objective is to return the maximum number of connecting lines that can be drawn between the two arrays without any line intersecting.
Given the root of a Binary Search Tree (BST), convert it into a Greater Tree where each node’s value is updated to the sum of its original value and all the values greater than it in the BST. The transformation should preserve the BST structure.