You are given a binary string s that represents the types of buildings along a street. Each building is either an office (‘0’) or a restaurant (‘1’). You are tasked with selecting 3 buildings for inspection, with the constraint that no two consecutive buildings in the selection can be of the same type. Return the number of valid ways to select 3 buildings where no two consecutive buildings are of the same type.
You are given two 24-hour formatted times, current and correct. Each time is represented in the format ‘HH:MM’, where HH is the hour (00 to 23) and MM is the minutes (00 to 59). In one operation, you can increase the current time by 1, 5, 15, or 60 minutes. Your task is to determine the minimum number of operations required to convert the current time to the correct time.
You are given a string expression in the form ‘+’, where and represent positive integers. Your task is to add a pair of parentheses to the expression such that the resulting expression evaluates to the smallest possible value. The parentheses must be placed around the ‘+’ operator. If there are multiple valid solutions yielding the same result, any of them can be returned.
You are given a string of digits, s, and an integer k. Your task is to repeatedly process the string until its length becomes less than or equal to k. In each step, divide the string into consecutive groups of size k. If the last group is smaller than k, process it as is. For each group, calculate the sum of its digits, convert the result back to a string, and merge all groups to form a new string. Repeat the process until the string length is ≤ k, and return the final string.
Given a list of strings words and a target string s, count how many strings in words are prefixes of s. A prefix is defined as a substring starting from the beginning of a string and extending up to a given length. Note that duplicate strings in words should be counted separately.
You are given a string number representing a positive integer and a character digit. Your task is to remove exactly one occurrence of digit from the string number such that the resulting number, when interpreted as an integer, is maximized. The test cases are guaranteed to have at least one occurrence of digit in the string.