You are given a grid of size m x n and two positions: the robot’s starting position (startPos) and its home position (homePos). The robot can move left, right, up, or down, with associated costs for moving to new rows and columns. Calculate the minimum total cost for the robot to move from its start position to its home position.
You are given an array of distinct integers. Your task is to remove the elements that hold the minimum and maximum values in the array. A deletion can either be from the front or the back of the array. Your objective is to find the minimum number of deletions required to remove both of these elements.
You are given a string s consisting of parentheses ‘(’ and ‘)’, and a binary string locked of the same length. Each position in locked determines whether the corresponding character in s can be changed or not. If locked[i] is ‘1’, the character s[i] cannot be modified, but if locked[i] is ‘0’, you can change s[i] to either ‘(’ or ‘)’. Your task is to determine if it is possible to make the string s a valid parentheses string by changing the positions where locked[i] is ‘0’. A valid parentheses string is defined by the following conditions: It is either ‘()’, or a concatenation of valid parentheses strings, or it can be written as (A) where A is a valid parentheses string.
You are given a planet with an initial mass. There are asteroids approaching the planet, each with its own mass. The planet can destroy an asteroid if its current mass is greater than or equal to the asteroid’s mass. After destroying an asteroid, the planet’s mass increases by the asteroid’s mass. You need to determine if the planet can destroy all the asteroids by strategically choosing the order of the collisions.
You are given an array of strings, where each string consists of two lowercase English letters. The task is to create the longest possible palindrome by selecting some of these strings and concatenating them in any order. Each string can be used at most once. A palindrome is a string that reads the same forward and backward. Return the length of the longest palindrome that can be created, or 0 if it’s not possible to create any palindrome.
You start with the integer 1, and you need to reach the target integer using the minimum number of moves. In one move, you can either increment the current integer by 1 or double it. The doubling operation can be used at most maxDoubles times.