text of even length n and a list of queries queries, where queries[i] = [a, b, c, d].
For a query you may:
- rearrange the letters at positions a through b inclusive in any order; this window lies in the left half of the string;
- rearrange the letters at positions c through d inclusive in any order; this window lies in the right half.
For each query, decide whether these rearrangements can turn text into a palindrome. Queries are independent: each one starts from the original string.
Return a list of True/False answers in query order.text='abccab', queries=[[0, 1, 4, 5], [0, 0, 3, 3]] → [True, False]
Query 0: rearrange the left window "ab" into "ba" to get "baccab", a palindrome. Query 1: both windows hold a single letter, so nothing changes, and "abccab" is not a palindrome.
text='xyzyzx', queries=[[1, 2, 3, 4]] → [True]
The outer "x" letters already mirror each other. Positions 1–4 all lie inside the windows, each side holds one "y" and one "z", so we can reach "xyzzyx", for example.
text='abcdef', queries=[[0, 2, 3, 5]] → [False]
The windows cover the whole string, but the left half holds a, b, c and the right half d, e, f, so no letter can be matched with its mirror.
text consists of lowercase English letterstext='abccab', queries=[[0, 1, 4, 5], [0, 0, 3, 3]]
[True, False]
Run checks the first 3 tests in your browser. Submit checks all 32 tests on the server, hidden ones included.