As reported: UBS intern-level online assessment (2025): a string
Sof lengthNandQqueries[l, r](0-based); each query reverses the substringS[l..r]in place. Return the final string.1 ≤ Q, N ≤ 10^5. The queries are applied in order, and their intervals can overlap.
Given a string s and a list of queries, where queries[i] = [l, r], apply the queries in order: each one reverses the characters s[l..r] (inclusive, 0-indexed) of the current string. Return the string after all queries.
Example 1
s = "abcdef", queries = [[1,3],[0,5]] -> "febcda"
[1,3]: a|bcd|ef → adcbef. [0,5]: reverse everything → febcda.
Example 2
s = "hello", queries = [[0,4],[0,4]] -> "hello"
Example 3
s = "x", queries = [[0,0]] -> "x"
Constraints: 1 ≤ n ≤ 10^5; 1 ≤ queries.length ≤ 10^5; 0 ≤ l ≤ r < n; s consists of lowercase English letters.
Code runner format: one JSON value per line: s, then queries. Implement reverseQueries(s, queries); the harness prints the final string as JSON.