Problem Statement:
Given a string s, the "type" of the string is defined by its first and last characters. For example, if s = "babdcaac", the type is "bc" (starts with 'b' and ends with 'c').
You can perform operations on the string to reduce its size, where one operation is equal to removing one character from the ends (effectively yielding a contiguous substring of the original string). Your goal is to maximize the number of operations performed such that the resulting string has the same type as the original string s.
(Note: Maximizing the operations is equivalent to finding the minimum length contiguous substring that starts with s[0] and ends with s[n-1]).
Example:
s = "babdcaac"
Valid resulting strings of type "bc" and their operations:
The maximum number of operations performed to yield a valid string is 5.
Problem Statement:
You are given a string data of lowercase English letters and a list of queries. There are two types of queries to process:
Return an array containing the results of all Type 2 queries.
Example:
data = "abfdpbp"
queries = [[2, 3, 6], [1, 5, 8], [2, 1, 2], [1, 4, 1], [1, 7, 4], [2, 1, 7]]
Output: [4, 2, 5]