You are given a string pattern consisting of the characters ‘I’ and ‘D’, where ‘I’ indicates that the next number in a sequence should be greater, and ‘D’ means the next number should be smaller. You need to construct the lexicographically smallest string num of length n + 1 such that the digits in num follow the conditions set by the pattern. The digits in num must be distinct and range from ‘1’ to ‘9’.
You are given a binary string s. In one second, all occurrences of the substring ‘01’ are simultaneously replaced with ‘10’. This process repeats until no occurrences of ‘01’ exist in the string. The task is to return the number of seconds required to complete this process.
You are given a string s consisting of lowercase English letters and a 2D array shifts. Each entry in the array represents a shift operation, where a segment of the string from starti to endi (inclusive) is shifted forward if directioni is 1, or backward if directioni is 0. A forward shift means replacing a character with the next letter in the alphabet (wrapping around from ‘z’ to ‘a’), and a backward shift means replacing a character with the previous letter (wrapping around from ‘a’ to ‘z’). You need to return the final string after all shifts are applied.
You are given a string num consisting only of digits. Your task is to form the largest possible palindromic number by rearranging the digits of num. The resulting number should not have leading zeros and must use at least one digit from the string.
You are given the root of a binary tree where each node has a unique value, and an integer start representing the initial infected node. At minute 0, the infection begins at the node with value start. Each minute, an adjacent uninfected node becomes infected. Your task is to return the total number of minutes it takes for the entire tree to become infected.
You are given a string s that contains lowercase English letters and stars (*). In each operation, you can choose a star in s, remove the closest non-star character to its left, and remove the star itself. Perform this operation until all stars are removed and return the resulting string.